#include <cstdio> #include <string> #include <algorithm> using namespace std; const int c[21] = { 'J', 'S', 'B', 'K', 'T', 'C', 'L', 'D', 'M', 'V', 'N', 'W', 'F', 'X', 'G', 'P', 'Y', 'H', 'Q', 'Z', 'R', }; const int v[5] = {'A', 'U', 'E', 'O', 'I'}; int main() { int T, C = 1; scanf("%d", &T); while (T--) { int l; scanf("%d", &l); int vi = 0, ci = 0, cnt[128] = {}; string vs, cs; printf("Case %d: ", C++); for (int i = 1; i <= l; i++) { if (i & 1) { vs += v[vi]; cnt[v[vi]]++; if (cnt[v[vi]] == 21) { vi++; } } else { cs += c[ci]; cnt[c[ci]]++; if (cnt[c[ci]] == 5) { ci++; } } } sort(vs.begin(), vs.end()); sort(cs.begin(), cs.end()); for (int i = 1; i <= l; i++) { if (i & 1) { putchar(vs[i / 2]); } else { putchar(cs[i / 2 - 1]); } } puts(""); } return 0; }
Hello, I am a CS student from Taiwan.
I am learing English and Programming.
I'll save source code of some problems or small programs without comments in this blog.
I would recommend you not to read solution from others before you solved the problem.
(這邊專門存放沒有任何註解的小程式/OJ題目程式碼)
2013年8月22日
UVa 10785 - The Mad Numerologist
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言