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 |
Re:我也用那个超变态的排查,为什么总是output limit?? 那位大仙是怎么变态过的啊?????In Reply To:我也用那个超变态的排查,为什么总是output limit?? 那位大仙是怎么变态过的啊????? Posted by:00448710 at 2006-08-02 14:45:04 #include<iostream> using namespace std; int main() { int a,b,w,x,y,t,i,j,min1,min2; while(scanf("%d%d%d",&a,&b,&w)!=EOF) { if(w==b) { printf("fill B\n");continue;} x=0; y=0; t=0; min1=1000; min2=1000; for(i=0;i<=1000;i++) for(j=0;j<=1000;j++) { if(a*i-b*j==w) { if(i<min1) min1=i; } if(a*i-b*j==-w) { if(j<min2) min2=j; } } // printf("%d %d\n",min1,min2); if(min2<=min1) { while(1) { printf("fill B\n"); x=b; printf("pour B A\n"); x=x-a+y; y=a; if(x==w) break; printf("empty A\n"); y=0; while(x!=0) { printf("pour B A\n"); if(x<a) { y=x; x=0; } if(x>=a) { x=x-a; y=a; } if(x==w) { t=1; break; } if(y==a) { printf("empty A\n"); y=0; } if(x==0) break; } if(t==1) break; } printf("success\n"); } if(min1<min2) { while(1) { printf("fill A\n"); y=a; if(y==w) break; while(y) { printf("pour A B\n"); if(x+a>=b) { x=b; y=y-b+a; } if(x+a<b) { x=x+a; y=0; } if(x==b) printf("empty B\n"); if(y==w) { t=1; break; } if(y==0) break; } if(t==1) break; } printf("pour A B\n"); printf("success\n"); } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator