/* -*- coding: utf-8 -*- * * 1624.cc: No.1624 三角形の反射 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100; /* typedef */ /* global variables */ char s[16]; /* subroutines */ template T gcd(T m, T n) { // m > 0, n > 0 if (m < n) swap(m, n); while (n > 0) { T r = m % n; m = n; n = r; } return m; } /* main */ int main() { scanf("%s", s); int gx = 1, gy = 0, pt = 0; for (int i = 0; s[i]; i++) { if (s[i] == '.') pt = 1; else { gy = gy * 10 + (s[i] - '0'); if (pt) gx *= 10; } } int g = gcd(gx, gy); gx /= g, gy /= g; //printf("%d,%d\n", gx, gy); int k = (gx - 1) + (gy - 1) + (gx + gy) / 2; for (int z = 1; z < gy; z += 2) { // y=x+z, y=(gy/gx)x // x=0 -> (0,z),(0,0), x=gx -> (gx,gx+z),(gx,gy) if (gx + z < gy) k++; } for (int z = -1; z > -gx; z -= 2) { if (gx + z > gy) k++; } int p = (gx + gy) & 1; // +C+C+C+ // B/C\B/C // +B+B+B+ // B\C/B\C // +C+C+C+ char c; if (p == 0) c = 'A'; else if (gx > gy) c = (gx & 1) ? 'B' : 'C'; else c = (gy & 1) ? 'C' : 'B'; printf("%c %d\n", c, k); return 0; }