标签:style blog io color os sp for 数据 div
2
5
1 2 3 4 5
5
45 10 48 37 9
35
334
1 #include <stdio.h> 2 #include <string.h> 3 4 int main(){ 5 int T; 6 int n; 7 int time; 8 int i; 9 int flag[101]; 10 int sum; 11 int temp; 12 int middle; 13 14 scanf("%d",&T); 15 16 while(T--){ 17 scanf("%d",&n); 18 19 memset(flag,0,sizeof(int)*101); 20 for(i=0;i<n;i++){ 21 scanf("%d",&time); 22 flag[time]++; 23 } 24 25 sum=0; 26 middle=0; 27 for(i=0;i<=100;i++){ 28 if(flag[i]!=0){ 29 temp=flag[i]; 30 31 while(temp--){ 32 middle+=i; 33 sum+=middle; 34 } 35 36 } 37 } 38 printf("%d\n",sum); 39 } 40 return 0; 41 }
标签:style blog io color os sp for 数据 div
原文地址:http://www.cnblogs.com/zqxLonely/p/4101374.html