UVa 12700 - Banglawash

Contents

  1. 1. Problem
  2. 2. Solution
  3. 3. Code

Problem

中文網址

Solution

記下各種情形(BWTA)的次數,稍微注意判斷的順序即可。

Code

UVa 12700
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<cstdio>

int main()
{
int Case;
scanf("%d", &Case);
for (int c = 1; c <= Case; c++)
{
int n, B = 0, W = 0, T = 0, A = 0;
scanf("%d", &n);
getchar();
for (int i = 0; i < n; i++)
{
char c = getchar();
if (c == 'B')
B++;
else if (c == 'W')
W++;
else if (c == 'T')
T++;
else if (c == 'A')
A++;
}
getchar();

printf("Case %d: ", c);
if (A == n)
puts("ABANDONED");
else if (B == n - A)
puts("BANGLAWASH");
else if (W == n - A)
puts("WHITEWASH");
else if (B == W)
printf("DRAW %d %d\n", B, T);
else if (B > W)
printf("BANGLADESH %d - %d\n", B, W);
else
printf("WWW %d - %d\n", W, B);
}

return 0;
}