UVA 11489 Integer Game——博弈
2018-03-09 14:07
435 查看
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn = 1005; char s[maxn]; int T, n; int main() { //freopen("out.txt", "w", stdout); scanf("%d", &T); for (int kase = 1; kase <= T; kase++) { cin >> s; n = strlen(s); if (n == 1) { printf("Case %d: S\n", kase); continue; } int sum = 0, cnt = 0; for (int i = 0; i < n; i++) { sum += s[i]-'0'; if ((s[i]-'0') % 3 == 0) cnt++; } if (sum % 3 == 0) { if (cnt % 2 == 0) printf("Case %d: T\n", kase); else printf("Case %d: S\n", kase); continue; } else { bool ok = false; for (int i = 0; i < n; i++) { if ((sum-s[i]+'0') % 3 == 0) { ok = true; break; } } if (!ok) { printf("Case %d: T\n", kase); continue; } else { if (cnt % 2 == 0) printf("Case %d: S\n", kase); else printf("Case %d: T\n", kase); continue; } } } return 0; }
相关文章推荐
- UVA11489Integer Game博弈
- (UVA - 11489)Integer Game(博弈)
- UVA 11489 - Integer Game 博弈
- UVa 11489 (博弈) Integer Game
- UVA 11489 - Integer Game 博弈
- UVa11489 - Integer Game(博弈)
- UVA 11489 Integer Game(博弈)
- UVA 11489 Integer Game(博弈,规律)
- UVa 11489 - Integer Game (简单博弈 脑筋急转弯)
- UVA 11489 - Integer Game(数论+博弈)
- UVA - 11489 Integer Game (博弈)
- Integer Game(UVA11489)3的倍数
- uva 11489 - Integer Game(水题)
- UVa 11489 - Integer Game
- Uva11489 Integer Game
- UVa11489 - Integer Game
- UVA 11489- Integer Game
- BNU19907 UVA11489 Integer Game
- uva11489 - Integer Game(考思维,找规律)
- UVa 11489 Integer Game (博弈&想法题)