标签:style http io ar color os sp for on
6 5 2 4 1 7 5 2 1 2
Case #1 The minimum number of moves is 5. <---华丽的分割线---> Case #2 No solution
#include<stdio.h> #include<algorithm> using namespace std; int main() { int i,n,a[100],sum,kase=1,ans; while(scanf("%d",&n)!=EOF) { for(i=0,sum=0;i<n;i++) { scanf("%d",&a[i]); sum+=a[i]; } if(kase==1) printf("Case #%d\n",kase++); else { printf("<---华丽的分割线--->\n"); printf("Case #%d\n",kase++); } if(sum%n) printf("No solution\n"); else { ans=sum/n; sort(a,a+n); for(i=0,sum=0;a[i]<ans;i++) { sum+=ans-a[i]; } printf("The minimum number of moves is %d.\n",sum); } } return 0; }
标签:style http io ar color os sp for on
原文地址:http://blog.csdn.net/hdd871532887/article/details/41780949