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 |
错了10次,那位大哥能帮小弟测下是那一组数据,过不了?#include <stdio.h> int main() { int count=1; while(1) { int i,a[6],s=0,k=0,k1=0; for(i=0;i<6;i++) { scanf("%d",a+i); if(a[i]==0) k++; if((i+1)%2==0) a[i]=a[i]%2; else { if((i+1)!=1) a[i]=a[i]%12; } s+=a[i]*(i+1); } if(k==6) break; if(s%2==1) { printf("Collection #%d:\nCan't be divided.\n\n",count++); continue; } int mid=s/2; int j=0; for(i=5;i>=0;i--) { for(j=0;j<a[i];j++) { mid-=i+1; if(mid<=0) break; } if(mid<0) mid+=i+1; if(mid==0) { printf("Collection #%d:\nCan be divided.\n\n",count++); break; } if(i==0&&mid>0) { int t; i=5; k1=0;; mid=s/2; for(t=5;t>=0;t--) //回溯 { if(a[t]>0) { a[t]--; break; } else k1++; } } if(k1==6) break; } if(mid>0) { printf("Collection #%d:\nCan't be divided.\n\n",count++); } } return 0; } 我用随机数测了好几百次都没错,一提交就WA,郁闷死了。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator