Help Johnny(类似杭电3568题)
Description
Input
Output
Please output the result in a single line for each list.
Sample Input
Sample Output
此题的意思就是给几组数据,按照一定的规则进行运算,要是知道规则很简单的运算。
代码如下:
#include<stdio.h>
#include <iostream>
using namespace std;
int a[100005];
int b[100005];
int main()
{
long long s1,s2,add;
int n,m,i,j=0;
cin>>n;
for(j=1;j<=n;j++)
{
add=0,s1=0,s2=0;
cin>>m;
for(i=1;i<=m;i++)
{
cin>>a[i]>>b[i];
s1+=a[i];
s2+=b[i];
}
for(i=1;i<m;i++)
{
s1-=a[i];
s2-=b[i];
add+=a[i]*s2+b[i]*s1;
}
cout<<add<<endl;
}
return 0;
}