【题外话:我......不补了......】

2015 ICL, Finals, Div. 2http://codeforces.com/gym/100637

G. #TheDress【水】

(strstr函数真好用......)

代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 char s[101];
 4 int main() {
 5     int n, i;
 6     scanf("%d ", &n);
 7     int x = 0, y = 0, z = 0;//地球人,外星人,其他人
 8     for(i = 1; i <= n; ++i) {
 9         gets(s);
10         if(strstr(s, "blue") && strstr(s, "black")) x++;
11         else if(strstr(s, "white") && strstr(s, "gold")) y++;
12         else z++;
13     }
14     printf("%.10f\n", x*100.0/(x+y+z));
15     printf("%.10f\n", y*100.0/(x+y+z));
16     printf("%.10f\n", z*100.0/(x+y+z));
17     return 0;
18 }
View Code

相关文章: