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 |
第一次用scanf和printf写代码,纪念一下,一次ac,0ms,纯模拟#include <cstdio> using namespace std; int main() { int s1,s2,s3,s4,s5,cnt; while(scanf("%d%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5,&cnt)!=EOF) { if(s1==0 && s2==0 && s3==0 && s4==0 && s5==0 && cnt==0)break; if(s5) { cnt+=s5; if(s1>11*s5) s1-=11*s5; else s1=0; } if(s4) { cnt+=s4; int use_s2; if(s2>5*s4) use_s2=5*s4; else use_s2=s2; s2-=use_s2; if(s1 && s1>20*s4-4*use_s2) s1-=(20*s4-4*use_s2); else s1=0; } if(s3) { cnt+=s3/4; s3%=4; if(s3)++cnt; if(s3==1) { int use_s2; if(s2 && s2>5)use_s2=5; else use_s2=s2; s2-=use_s2; if(s1 && s1>27-use_s2*4) s1-=(27-use_s2*4); else s1=0; } else if(s3==2) { int use_s2; if(s2 && s2>3)use_s2=3; else use_s2=s2; s2-=use_s2; if(s1 && s1>18-use_s2*4) s1-=(18-use_s2*4); else s1=0; } else if(s3==3) { int use_s2; if(s2 && s2>1)use_s2=1; else use_s2=s2; s2-=use_s2; if(s1 && s1>9-use_s2*4) s1-=(9-use_s2*4); else s1=0; } } if(s2) { cnt+=s2/9; s2%=9; if(s2) { ++cnt; if(s1 && s1>36-4*s2)s1-=36-4*s2; else s1=0; } } if(s1) { cnt+=s1/36; s1%=36; if(s1)++cnt; } printf("%d\n",cnt); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator