当前位置:网站首页>-Vector Dot Product-
-Vector Dot Product-
2022-08-10 01:46:00 【-JMY-】
Title description
Vector dot product is a very important operation in linear algebra and computational geometry.
Given two n-dimensional vectors a=(a1,a2,...,an) and b=(b1,b2,...,bn), find the dot product a·b=a1b1+a2b2+...+anbn.
Enter
The first line is an integer n.1 <= n <= 1000.
The second line contains n integers a1,a2,...,an.
The third line contains n integers b1,b2,...,bn.
Adjacent integers are separated by a single space.The absolute value of each integer does not exceed 1000.
Output
An integer, the result of the dot product of two vectors.
Sample input
31 4 62 1 5
Sample output
36
Reference code:
#include
using namespace std;
int n,a[1005],b[1005],s;
int main(){
scanf("%d",&n);
for(int i=0;i
for(int i=0;i
for(int i=0;i
printf("%d",s);
return 0;
}
边栏推荐
猜你喜欢
随机推荐
【问题解决】训练和验证准确率很高,但测试准确率很低
数字孪生智慧制造生产线项目实施方案,平台认知与概念
Project (7) - PolarSeg point cloud semantic segmentation
Copper's emotion
【剑指offer】第一题 第二题
服装店管理系统如何推送活动?
[SSH]如何敲一条线
有PEG-Biotin参与的(CAS:1778736-18-7)Biotin-PEG4-OH广泛用于分子靶点检测
3.9 - 正规表达式和正规集 3.10 - 有限自动机
Why don't suggest you run in Docker Mysql?
FITC标记生物素(FITC-生物素|CAS:134759-22-1)有哪些知识了?
c语言文件基本操作总结
第十二,十三章 mysql数据类型,视图的课后练习
deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试
Leetcode79. 单词搜索
JSP简介
When knowledge and action are one
MATLB|和她跌宕起伏最终到达人生之峰【浪漫旅途】
PEG 衍生物Biotin-PEG1-OH(cas:95611-10-2,2-生物素氨基乙醇)优势说明
足不出户也能看星空