原题
题目分析
无脑贪心枚举题,只是码起来麻烦,想清楚后基本没什么问题.
代码
1 #include <iostream> 2 #include <algorithm> 3 #include <utility> 4 #include <cstdio> 5 #include <cmath> 6 #include <cstring> 7 #include <string> 8 #include <vector> 9 #include <stack> 10 #include <queue> 11 #include <map> 12 #include <set> 13 14 using namespace std; 15 typedef long long LL; 16 const int INF_INT=0x3f3f3f3f; 17 const LL INF_LL=0x3f3f3f3f3f3f3f3f; 18 19 int main() 20 { 21 // freopen("black.in","r",stdin); 22 // freopen("black.out","w",stdout); 23 int a,b,c,d,e,f; 24 while(~scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)&&(a||b||c||d||e||f)) 25 { 26 int ans=0; 27 if(f) ans+=f; 28 if(e) 29 { 30 ans+=e; 31 a=max(0,a-11*e); 32 } 33 if(d) 34 { 35 ans+=d; 36 d*=5; 37 if(b-d<=0) d-=b,b=0,a=max(0,a-4*d); 38 else b-=d; 39 } 40 if(c) 41 { 42 ans+=c/4; 43 if(c%4) ans++; 44 c%=4; 45 if(c==1) 46 { 47 int one=10,two=5; 48 if(b-two<=0) two-=b,b=0,one+=two*4; 49 else b-=two; 50 a=max(0,a-one); 51 } 52 if(c==2) 53 { 54 int one=6,two=3; 55 if(b-two<=0) two-=b,b=0,one+=two*4; 56 else b-=two; 57 a=max(0,a-one); 58 } 59 if(c==3) 60 { 61 int one=5,two=1; 62 if(b-two<=0) two-=b,b=0,one+=two*4; 63 else b-=two; 64 a=max(0,a-one); 65 } 66 } 67 if(b) 68 { 69 ans+=b/9; 70 if(b%9) ans++; 71 b%=9; 72 b=9-b; 73 a=max(0,a-b*4); 74 } 75 if(a) 76 { 77 ans+=a/36; 78 if(a%36) ans++; 79 } 80 printf("%d\n",ans); 81 } 82 return 0; 83 }