当前位置:网站首页>NOI OPENJUDGE 1.6(09)
NOI OPENJUDGE 1.6(09)
2022-07-03 14:37:00 【two billion seven hundred and fifty-eight million seven hundred】
23: Vector dot product calculation
Total time limit :
1000ms
Memory limit :
65536kB
describe
In Linear Algebra 、 In Computational Geometry , Vector dot product is a very important operation .
Given two n Dimension vector a=(a1,a2,...,an) and b=(b1,b2,...,bn), Find the dot product a·b=a1b1+a2b2+...+anbn.
Input
The first line is an integer n.1 <= n <= 1000.
The second line contains n It's an integer a1,a2,...,an.
The third line contains n It's an integer b1,b2,...,bn.
Separate adjacent integers with a single space . The absolute value of each integer does not exceed 1000
Output
An integer , That is, the result of the dot product of two vectors .
The sample input
3
1 4 6
2 1 5
Sample output
36
Analysis and code :[ author : Lu changheel ]:
analysis : Enter the dimension of the vector first , Then input two vectors according to the dimension ( Save in an array ),
Then calculate the dot product , Just output
Code :
#include<iostream>
usingnamespace std;
int main()
{
int a;
cin >> a;
int b[1000];
int c[1000];
for (int i = 0; i < a; i++)
{
cin >> b[i];
}
for (int i = 0; i < a; i++)
{
cin >> c[i];
}
int all = 0;
for (int i = 0; i < a; i++)
{
all = all + b[i] * c[i];
}
cout << all;
return 0;
}
边栏推荐
- 7-18 finding the single root of polynomial by dichotomy
- Tonybot humanoid robot starts for the first time 0630
- Zzuli:1041 sum of sequence 2
- 7-17 crawling worms (break exercise)
- Zzuli: sum of 1051 square roots
- 7-1 positive integer a+b (15 points)
- String reverse order
- Zzuli:1058 solving inequalities
- 7-16 find the set of integers that meet the given conditions
- 分布式事务(Seata) 四大模式详解
猜你喜欢

dllexport和dllimport

Bucket sorting in C language

Code writing and playing method of tonybot humanoid robot at fixed distance

Talking about part of data storage in C language

Protobuf and grpc

retrofit

Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules

天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库

Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue

MySQL multi table query subquery
随机推荐
Luogu p5536 [xr-3] core city solution
Convert string to decimal integer
数学常数表 by q779
Mongodb index
洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解
Puzzle (016.3) is inextricably linked
光猫超级账号密码、宽带账号密码 获取
Tonybot humanoid robot checks the port and corresponds to port 0701
Protobuf and grpc
Analysis of gene family characteristics - chromosome location analysis
Common commands for getting started with mongodb database
Etcd cluster permission management and account password usage
China PETG market forecast and Strategic Research Report (2022 Edition)
7-1 positive integer a+b (15 points)
Puzzle (016.4) domino effect
Bucket sorting in C language
Ultra simple mobile map development
Get permissions dynamically
retrofit
Optical cat super account password and broadband account password acquisition