当前位置:网站首页>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;
}
边栏推荐
- How Facebook moves instagram from AWS to its own server
- Zzuli:1040 sum of sequence 1
- 7-19 check denomination (solve binary linear equation)
- Output student grades
- Zzuli:1045 numerical statistics
- String reverse order
- 关于敏捷的一些概念
- Why is this error reported when modifying records in the database
- tonybot 人形機器人 紅外遙控玩法 0630
- Zabbix添加Calculated items后保存页面成空白
猜你喜欢
dllexport和dllimport
Sub GHz wireless solution Z-Wave 800 Series zg23 SOC and zgm230s modules
Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
Tonybot Humanoïde Robot Infrared Remote play 0630
Tonybot humanoid robot infrared remote control play 0630
Bucket sorting in C language
7-15 calculation of PI
Protobuf and grpc
tonybot 人形机器人 红外遥控玩法 0630
Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
随机推荐
adc128s022 ADC verilog设计实现
Use of form text box (I) select text
7-18 finding the single root of polynomial by dichotomy
分布式事务(Seata) 四大模式详解
ConstraintLayout 的使用
Zzuli:1045 numerical statistics
Find the sum of the elements of each row of the matrix
X86 assembly language - Notes from real mode to protected mode
Understand the application scenario and implementation mechanism of differential segment
Tonybot Humanoïde Robot Infrared Remote play 0630
Amazon, express, lazada, shopee, eBay, wish, Wal Mart, Alibaba international, meikeduo and other cross-border e-commerce platforms evaluate how Ziyang account can seize traffic by using products in th
Code writing and playing method of tonybot humanoid robot at fixed distance
String reverse order
Sword finger offer 28 Symmetric binary tree
Zzuli:1047 logarithmic table
7-16 find the set of integers that meet the given conditions
C language to realize mine sweeping
分布式事务(Seata) 四大模式详解
洛谷P5536 【XR-3】核心城市 题解
Convert string to decimal integer