Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 51871 | Accepted: 17612 |
Description
Input
Output
Sample Input
0 0 4 0 0 1 7 5 1 0 0 0 0 0 0 0 0 0
Sample Output
2 1
Source
1 #include <iostream> 2 #include <algorithm> 3 #include <map> 4 #include <vector> 5 #include <functional> 6 #include <string> 7 #include <cstring> 8 #include <queue> 9 #include <stack> 10 #include <set> 11 #include <cmath> 12 #include <cstdio> 13 using namespace std; 14 #define IOS ios_base::sync_with_stdio(false) 15 typedef long long LL; 16 const int INF = 0x3f3f3f3f; 17 const double PI=4.0*atan(1.0); 18 19 LL ans; 20 int c1,c2,c3,c4,c5,c6; 21 int main() 22 { 23 while(scanf("%d%d%d%d%d%d",&c1,&c2,&c3,&c4,&c5,&c6)==6){ 24 if(c1+c2+c3+c4+c5+c6==0)return 0; 25 ans=0; 26 ans+=c6+c5; 27 c1-=c5*11; 28 if(c4>0){ 29 ans+=c4; 30 int num=c4*5; 31 if(c2>num) c2-=num; 32 else c1-=(num-c2)*4,c2=0; 33 } 34 ans+=c3/4; 35 c3%=4; 36 if(c3!=0) ans++; 37 if(c3==1){ 38 if(c2>=5){ 39 c2-=5; 40 }else{ 41 c1-=20-c2*4; 42 c2=0; 43 } 44 c1-=7; 45 }else if(c3==2){ 46 if(c2>=3) c2-=3; 47 else{ 48 c1-=12-c2*4; 49 c2=0; 50 } 51 c1-=6; 52 }else if(c3==3){ 53 if(c2>0) c2--; 54 else c1-=4; 55 c1-=5; 56 } 57 if(c1<0) c1=0; 58 if(c2>0){ 59 ans+=c2/9; 60 if(c2%9){ 61 ans++; 62 c1-=36-(c2%9)*4; 63 } 64 } 65 if(c1>0){ 66 ans+=c1/36; 67 if(c1%36) ans++; 68 } 69 printf("%lld\n",ans); 70 } 71 return 0; 72 }
原文:http://www.cnblogs.com/cumulonimbus/p/5830667.html