当前位置:网站首页>-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;
}
边栏推荐
猜你喜欢
安全知识培训——消防安全
Leetcode80. 删除有序数组中的重复项 II
2022中高级Android面试题汇总来助你通过面试
CAS:851113-28-5 (生物素-ahx-ahx-酪胺)
deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试
JVM Memory and Garbage Collection - 10. Direct Memory
拒绝“重复造轮子”,百度EasyDL让你玩转AI定制开发
go语言的并发原理(goroutine)
【数据存储】signed,unsigned到底怎么区分?如何计算?
Linux安装Oracle和postgrepSQL数据库
随机推荐
E - Sugoroku 3(期望dp)
Leetcode80. 删除有序数组中的重复项 II
Service Discovery @EnableDiscoveryClient
20220808-一些想法
Redis 大 key 要如何处理?
JVM Memory and Garbage Collection - 10. Direct Memory
Stanford CS143 速通PA1教程
线程的同步与互斥
Leecode-205. 同构字符串
3.9 - 正规表达式和正规集 3.10 - 有限自动机
Redis redisTemplate.execute 执行锁
足不出户也能看星空
阿雷的血压有些低
365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心
分形网络(FractalNet)----学习笔记
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
Kubernetes服务接入Istio
NTP SERVICE TASK 在GWserver配置、启用NTP服务,为当前环境提供时钟同步服务,Client主机可以从该服务器同步时间。
WPF DataGrid 使用数据模板
深度剖析 Apache EventMesh 云原生分布式事件驱动架构