首页 > 代码库 > CSU七月校赛B

CSU七月校赛B

技术分享
#include <iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>using namespace std;int cmp(int a,int b){    return a>b;}int a[100000],b[100000];int main(){    int n;    int t;    int sum;    scanf("%d",&t);    while(t--)    {        sum=0;        scanf("%d",&n);        for(int i=0;i<n;i++)        {            scanf("%d",&a[i]);        }        sort(a,a+n,cmp);        for(int i=0;i<n;i++)        {            scanf("%d",&b[i]);        }        sort(b,b+n);        sum=0;        for(int i=0,j=0;i<n,j<n;i++,j++)        {            sum += (a[i]-b[j])*(a[i]-b[j]);        }        printf("%d\n",sum);//错了,lld!!    }    return 0;}
View Code

 

CSU七月校赛B