当前位置:网站首页>[diary of supplementary questions] [2022 Niuke summer multi school 2] i-let fat tension
[diary of supplementary questions] [2022 Niuke summer multi school 2] i-let fat tension
2022-07-28 11:55:00 【cls1277】
Pro
https://ac.nowcoder.com/acm/contest/33187/I
Sol
It's actually a simple calculation problem , However, the list was skewed during the game, so no one looked at this question .
Next, simplify the formula ( Increased subscript o Means Y The subscript of each component of a vector ): Y i n e w = ∑ j = 1 n ∑ p = 1 k X i p ⋅ X j p ∣ X i ∣ ⋅ ∣ X j ∣ Y i Y_{i}^{new}=\sum_{j=1}^{n}\sum_{p=1}^{k}\frac{X_{ip}·X_{jp}}{|X_i|·|X_j|}Y_{i} Yinew=j=1∑np=1∑k∣Xi∣⋅∣Xj∣Xip⋅XjpYi
Y i , o n e w = ∑ j = 1 n ∑ p = 1 k X i p ⋅ X j p ∣ X i ∣ ⋅ ∣ X j ∣ Y i , o Y_{i,o}^{new}=\sum_{j=1}^{n}\sum_{p=1}^{k}\frac{X_{ip}·X_{jp}}{|X_i|·|X_j|}Y_{i,o} Yi,onew=j=1∑np=1∑k∣Xi∣⋅∣Xj∣Xip⋅XjpYi,o
Y i , o n e w = ∑ j = 1 n ∑ p = 1 k X i p ∣ X i ∣ ⋅ X j p ∣ X j ∣ Y i , o Y_{i,o}^{new}=\sum_{j=1}^{n}\sum_{p=1}^{k}\frac{X_{ip}}{|X_i|}·\frac{X_{jp}}{|X_j|}Y_{i,o} Yi,onew=j=1∑np=1∑k∣Xi∣Xip⋅∣Xj∣XjpYi,o
Y i , o n e w = ∑ p = 1 k ( X i p ∣ X i ∣ ⋅ ∑ j = 1 n X j p ∣ X j ∣ Y i , o ) Y_{i,o}^{new}=\sum_{p=1}^{k}(\frac{X_{ip}}{|X_i|}·\sum_{j=1}^{n}\frac{X_{jp}}{|X_j|}Y_{i,o}) Yi,onew=p=1∑k(∣Xi∣Xip⋅j=1∑n∣Xj∣XjpYi,o)
Make Z p , o = ∑ j = 1 n X j p ∣ X j ∣ Y i , o Z_{p,o}=\sum_{j=1}^{n}\frac{X_{jp}}{|X_j|}Y_{i,o} Zp,o=∑j=1n∣Xj∣XjpYi,o, be
Y i , o n e w = ∑ p = 1 k ( X i p ∣ X i ∣ ⋅ Z p , o ) Y_{i,o}^{new}=\sum_{p=1}^{k}(\frac{X_{ip}}{|X_i|}·Z_{p,o}) Yi,onew=p=1∑k(∣Xi∣Xip⋅Zp,o)
It can be preprocessed directly after input X i , p ∣ X i ∣ \frac{X_{i,p}}{|X_i|} ∣Xi∣Xi,p and X j , p ∣ X j ∣ \frac{X_{j,p}}{|X_j|} ∣Xj∣Xj,p, It can be seen that calculation Z p , o Z_{p,o} Zp,o and Y i , o n e w Y_{i,o}^{new} Yi,onew And the time complexity of each is O ( n k d ) O(nkd) O(nkd)
Code
//By cls1277
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define Fo(i,a,b) for(LL i=(a); i<=(b); i++)
#define Ro(i,b,a) for(LL i=(b); i>=(a); i--)
#define Eo(i,x,_) for(LL i=head[x]; i; i=_[i].next)
#define Ms(a,b) memset((a),(b),sizeof(a))
#define endl '\n'
const LL maxn = 1e4+5;
LL n, k, d;
double x[maxn][55], y[maxn][55], z[maxn][55], ans[maxn][55];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef DEBUG
freopen("data.txt","r",stdin);
#endif
cin>>n>>k>>d;
Fo(i,1,n) {
double len = 0;
Fo(j,1,k) {
cin>>x[i][j];
len += x[i][j]*x[i][j];
}
len = sqrt(len);
Fo(j,1,k) x[i][j] /= len;
}
Fo(i,1,n)
Fo(j,1,d)
cin>>y[i][j];
Fo(i,1,n)
Fo(j,1,k)
Fo(l,1,d)
z[j][l] += x[i][j]*y[i][l];
Fo(i,1,n)
Fo(j,1,d)
Fo(l,1,k)
ans[i][j] += x[i][l]*z[l][j];
Fo(i,1,n) {
Fo(j,1,d)
cout<<fixed<<setprecision(8)<<ans[i][j]<<' ';
cout<<endl;
}
return 0;
}
边栏推荐
- The reflect mechanism obtains the attribute and method information of class
- Service Workers让网站动态加载Webp图片
- 中国业务型CDP白皮书 | 爱分析报告
- 在生产环境中每天Oracle监控到的无效对象一般怎么去处理?
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- 大佬们,问下,这个不能checkpoint,因为有个jdbc的task任务状态是FINISHED,
- 移动端人脸风格化技术的应用
- What is the process of switching c read / write files from user mode to kernel mode?
- How to use JWT for authentication and authorization
- Multithreading and high concurrency (III) -- source code analysis AQS principle
猜你喜欢

Redis installation

Four advantages of verification code to ensure mailbox security

Xiaoshuidi 2.0 website navigation network template

In order to ensure the normal operation of fire-fighting equipment in large buildings, the power supply monitoring system of fire-fighting equipment plays a key role

数字孪生轨道交通:“智慧化”监控疏通城市运行痛点

Minikube initial experience environment construction

Update dev (development version) of the latest win11
![[applet] how to notify users of wechat applet version update?](/img/04/848a3d2932e0dc73adb6683c4dca7a.png)
[applet] how to notify users of wechat applet version update?

LabVIEW AI视觉工具包(非NI Vision)下载与安装教程

Upgrading of computing power under the coordination of software and hardware, redefining productivity
随机推荐
中国业务型CDP白皮书 | 爱分析报告
Redis安装
Ripro9.0 revised and upgraded version +wp two beautification packages + rare plug-ins
Detailed explanation of boost official website search engine project
Anonymous subclass objects of abstract classes
Solutions to slow start of MATLAB
Good use explosion! The idea version of postman has been released, and its functions are really powerful
Object stream of i/o operation (serialization and deserialization)
简单选择排序与堆排序
Can dynamic partitions be configured when MySQL is offline synchronized to ODPs
[general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials
STL の 概念及其应用
Leecode8 string conversion integer (ATOI)
R language ggplot2 visualization: use the ggboxplot function of ggpubr package to visualize the box diagram and customize the fill parameter to configure the filling color of the box
【MySQL】Got an error reading communication packets
What is the process of switching c read / write files from user mode to kernel mode?
A new mode of one-stop fixed asset management
ASP. Net core 6 framework unveiling example demonstration [29]: building a file server
P5472 [NOI2019] 斗主地(期望、数学)
【补题日记】[2022牛客暑期多校2]L-Link with Level Editor I