标签:des style http color io os java ar strong
3 6 100 100 100 99 98 101 6 100 100 100 99 99 101 6 100 100 98 99 99 97
Case #1: 10000 Case #2: Bad Mushroom Case #3: 9999 10000
显然,最多只有200种情况,可以直接桶排。
唯一要注意的是Bad Mushroom的特例:s不全相同,但是众数全都一样
#include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cmath> #include<algorithm> #include<iostream> using namespace std; #define MAXN (1000000+10) #define For(i,n) for(int i=1;i<=n;i++) #define Fork(i,k,n) for(int i=k;i<=n;i++) #define Rep(i,n) for(int i=0;i<n;i++) #define ForD(i,n) for(int i=n;i;i--) #define RepD(i,n) for(int i=n;i>=0;i--) #define Forp(x) for(int p=pre[x];p;p=next[p]) #define Lson (x<<1) #define Rson ((x<<1)+1) #define MEM(a) memset(a,0,sizeof(a)); #define MEMI(a) memset(a,127,sizeof(a)); #define MEMi(a) memset(a,128,sizeof(a)); int T,n; struct num { int a,s; num(){} num(int _a):a(_a){} }a[MAXN]; int c[MAXN]; int m,d[MAXN]; int main() { cin>>T; For(t,T) { MEM(c) MEM(d) scanf("%d",&n); m=0; For(i,n) scanf("%d",&a[i].a),a[i].s=10000-(100-a[i].a)*(100-a[i].a); For(i,n) c[(int)abs(a[i].a-100)]++; int p=-1; Rep(i,101) if (c[i]>p) p=c[i]; RepD(i,100) if (c[i]==p) d[++m]=i; printf("Case #%d:\n",t); if (m*p==n&&m>1) printf("Bad Mushroom\n"); else { For(i,m-1) { printf("%d ",10000-d[i]*d[i]); } printf("%d\n",10000-d[m]*d[m]); } } return 0; }
标签:des style http color io os java ar strong
原文地址:http://blog.csdn.net/nike0good/article/details/39546071