#include #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { double a; cin >> a; int x = 1000, y = 1000 * a; int g = gcd(x, y); int p = x / g, q = y / g, ans = 0; if ((p + q) % 2 == 0) { cout << "A"; ans = -1; } else if (p % 2) { cout << "B"; ans = -2; if (a > 1) ans--; } else { cout << "C"; ans = -2; if (a > 1) ans--; } int s = 0; ans += p - 1; rep(i, 0, p) { int t = s + y, u = s / 1000, v = t / 1000; if (u == v) { ans++; } else { ans += v - u; ans += v - u - 1; if (i % 2 == u % 2) ans++; if (i % 2 == v % 2) ans++; } s = t; } cout << " " << ans << endl; }