Codeforces Round #190 (Div. 2) B. Ciel and Flowers

链接:http://codeforces.com/contest/322/problem/B

这题做错了。没考虑周全。

 1 #include <cstdio>
 2 #include <cstdlib>
 3 #include <iostream>
 4 #include <algorithm>
 5 using namespace std;
 6 int main(void)
 7 {
 8     int r, g, b;
 9     while (~scanf("%d%d%d", &r, &g, &b)) {
10         int x = r % 3, y = g % 3, z = b % 3, Max = max(x, max(y, z)), cnt =r/3+g/3+b/3;
11         if (Max == 1) {
12             if (x == y && y == z && x == 1) cnt++;
13         } 
14                 if (Max == 2) {
15             if (x + y + z == 4) {
16                             if (x*y*z) cnt++;
17                             else if (!x && r/3) cnt++;
18                             else if (!y && g/3) cnt++;
19                             else if (!z && b/3) cnt++;
20                         }
21                         else if (x + y + z == 5) cnt++;
22             else if (x + y + z == 6) cnt+=2;
23         }
24         printf("%d
", cnt);
25     }
26 
27     return 0;
28 }

。。

。。

原文地址:https://www.cnblogs.com/liuxueyang/p/3169398.html