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 |
能不能帮我看看呀!万分感谢!我都试了好多遍了 都是WA哦In Reply To:测试了一些数据 都是对的呀! Posted by:697851 at 2010-05-18 09:32:49 #include<iostream> using namespace std; int main() { int a[6]; int i,num=0,left=0,flag=0; while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5],a[0]||a[1]||a[2]||a[3]||a[4]||a[5]) { if( a[5] > 0 ) num = num + a[5]; if( a[4] > 0 ) { for( i = 0; i < a[4]; i++ ) { num ++; if(a[0] > 0) a[0] = a[0] - 11; } } if( a[3] > 0 ) { for( i = 0; i < a[3]; i++ ) { num ++; if(a[1] > 0) { a[1] = a[1] - 5; flag = 1; } if(a[1] <= 0 && a[0] > 0) { if( flag == 1 ) { a[0] -= (0 - a[1]) * 4; a[1] = 0; flag = 0; } else if( flag == 0 ) a[0] -= 20; } } } flag = 0; if( a[2] > 0 ) { if( a[2] >= 4 ) num = num + a[2]/4; a[2] = a[2] % 4; left = 4 - a[2]; if( left == 3 ) { num++; if( a[1] > 0 ) { a[1] = a[1] - 5; flag = 1; } if( a[0] > 0 && a[1] <= 0 ) { if(flag == 1) { a[0] = a[0] - (a[1] * -4 ) - 7; a[1] = 0; flag = 0; } else if(flag == 0) a[0] = a[0] - 27; } } else if( left == 2 ) { num++; if( a[1] > 0 ) { a[1] = a[1] - 3; flag = 1; } if( a[0] > 0 && a[1] <= 0 ) { if(flag == 1) { a[0] = a[0] - a[1] * -4 - 6; a[1] = 0; flag = 0; } else if(flag ==0) a[0] = a[0] - 18; } } else if( left == 1 ) { num++; if( a[1] > 0 ) { a[1] = a[1] - 1; flag = 1; } if( a[0] > 0 ) { if( a[1] <= 0 ) { if(flag == 1) { a[0] = a[0] - a[1] * -4 -5; a[1] = 0; flag = 0; } else if(flag == 0) a[0] = a[0] - 9; } } } } if(a[1] > 0) { if( a[1] >= 9 ) num = num + a[1]/9; a[1] = a[1] % 9; if( a[1] != 0 ) { num++; if(a[0] > 0) a[0] = a[0] -(9 - a[1]) * 4; } } if(a[0] > 0) { if( a[0] >= 36 ) num = num + a[0]/36; a[0] = a[0] % 36; if( a[0] != 0 ) num++; } cout << num <<endl; flag = 0; left = 0; num = 0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator