2016-05-19 Problem Solving►ZeroJudge ZeroJudge b309 - 聖杯戰爭 Contents 1. Problem2. Solution3. Code Problem題目網址A ~ J 對應其代表的英靈,接下來的字母也比照辦理。 Solution注意英靈順序即可。 CodeZJ b309ZJ b309123456789101112131415161718192021222324252627282930313233#include<cstdio>#include<cstring>#include<cctype>#define N 10000001char str[N];int main(){ char *name[7] = { "Saber", "Lancer", "Archer", "Rider", "Caster", "Assassin", "Berserker" }; int n[7] = {}, i; while (fgets(str, N, stdin)) { int len = strlen(str); for (i = 0; i < len; i++) { if (isalpha(str[i])) n[(tolower(str[i]) - 'a') % 7]++; } } int max = 0; for (i = 0; i < 7; i++) if (max < n[i]) max = n[i]; for (i = 7; i >= 0; i--) if (n[i] == max) { puts(name[i]); break; } return 0;} Newer UVa 993 - Product of digits Older UVa 750 - 8 Queens Chess Problem