标签:bsp problem 重要 ams ret ble 计算 空格 can
在线性代数、计算几何中,向量点积是一种十分重要的运算。
给定两个n维向量a=(a1,a2,...,an)和b=(b1,b2,...,bn),求点积a·b=a1b1+a2b2+...+anbn。
3 1 4 6 2 1 5
36
代碼實現:
1 #include<cstdio> 2 int n,a[1010],b[1010],ans; 3 int main(){ 4 scanf("%d",&n); 5 for(int i=1;i<=n;i++) scanf("%d",&a[i]); 6 for(int i=1;i<=n;i++) scanf("%d",&b[i]); 7 for(int i=1;i<=n;i++) ans+=a[i]*b[i]; 8 printf("%d\n",ans); 9 return 0; 10 }
。。。
标签:bsp problem 重要 ams ret ble 计算 空格 can
原文地址:http://www.cnblogs.com/J-william/p/6155224.html