| ||||||||||
| 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:纯模拟……WA了一次,发现打错一个地方,再提交AC……In Reply To:纯模拟……WA了一次,发现打错一个地方,再提交AC…… Posted by:dashashi at 2009-12-09 15:27:10 > 贴上代码~
>
> #include <iostream>
>
> using namespace std;
>
> int main()
> {
> int a, b, c, d, e, f, ans;
> while(1)
> {
> cin >> a >> b >> c >> d >> e >> f;
> ans = 0;
> if (a+b+c+d+e+f == 0)
> break;
> ans += f;
> if (e > 0)
> {
> ans += e;
> a -= 11*e;
> }
> if (d > 0)
> {
> ans += d;
> b -= 5*d;
> }
> if (c > 0)
> {
> ans += c / 4;
> c = c % 4;
> switch(c)
> {
> case 0: break;
> case 1: ans++; b-=5; a-=7;break;
> case 2: ans++; b-=3; a-=6;break;
> case 3: ans++; b-=1; a-=5;break;
> }
> }
> if (b < 0)
> a += b*4;
> else if (b > 0)
> {
> ans += b/9;
> b = b % 9;
> if (b != 0)
> {
> ans ++;
> a -= (36-b*4);
> b = 0;
> }
> }
> if (a > 0)
> {
> ans += a/36;
> a = a% 36;
> if (a != 0)
> ans++;
> }
> cout << ans << endl;
> }
>
> return 0;
> }
可以小于0这个思想太好了
刚开始用的笨方法就是1^1 2^2都不能小于0的,所以会多出来好多的if。
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator