Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
晕啊,怎么还是WA,高手请进!#include <iostream.h> void main() { int i,j,k,m,n,p,s,q,temp,total,flag; int a[100]; int b[100]; int an[1000]; for (s=1;;s++) { total=0; cin >>n; if (n==0)break; flag=0; for (p=1;p<=n;p++) { cin >>a[p]; total=total+a[p]; if (a[p]<=0||a[p]>50) { flag=1; } } if (flag==1) { an[s]=0; continue; } for (p=1;p<=n;p++) { for (q=p;q<=n;q++) { if (a[p]<a[q]) { temp=a[p]; a[p]=a[q]; a[q]=temp; } } } for (j=total;j>=a[1];j--) { for (p=1;p<=n;p++)b[p]=a[p]; if ((total%j)==0)p=j; else { continue; } for (i=1;i<=1000;i++) { p=j; for (k=1;k<=n;k++) { if (p>=b[k]) { p=p-b[k]; b[k]=0; } if (p==0)break; } m=0; for (k=1;k<=n;k++) m=m+b[k]; if (m==0) { an[s]=j; break; } else { if (p!=0) break; } } } } for (p=1;p<=s-1;p++) { if (an[p]!=0)cout<<an[p]<<endl; } } 测试没啥问题的啊~~~~~~~~~~~~~拜托高手在百忙之中指点一下 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator