#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; typedef complex P; namespace std { bool operator < (const P& a, const P& b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } P operator + (const P&a, const P & b) { return P(a.real() + b.real(), a.imag() + b.imag()); } } const double EPS = 1e-9; struct L : public vector

{ L() {} L(const P &a, const P &b) { push_back(a); push_back(b); } }; double cross(const P& a, const P& b) { return imag(conj(a)*b); } double dot(const P& a, const P& b) { return real(conj(a)*b); } int ccw(P a, P b, P c) { b -= a; c -= a; if (cross(b, c) > 0) return +1; // counter clockwise if (cross(b, c) < 0) return -1; // clockwise if (dot(b, c) < 0) return +2; // c--a--b on line if (norm(b) < norm(c)) return -2; // a--b--c on line return 0; } bool intersectSS(const L &s, const L &t) { return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0; } P crosspoint(const L &l, const L &m) { double A = cross(l[1] - l[0], m[1] - m[0]); double B = cross(l[1] - l[0], l[1] - m[0]); if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!! return m[0] + B / A * (m[1] - m[0]); } void resize(P &p) { double length = 4; p /= abs(p); p *= length; } signed main() { double a; cin >> a; P now = P(0, 0); P dir = P(1, a); resize(dir); //cout << "dir = [" << dir.real() / 4 << ", " << dir.imag() / 4 << "]" << endl; P ps[3] = {P(0, 0), P(1, 0), P(0, 1)}; L ls[3]; L ab = L(P(0, 0), P(1, 0)); L bc = L(P(1, 0), P(0, 1)); L ca = L(P(0, 1), P(0, 0)); ls[0] = ab; ls[1] = bc; ls[2] = ca; string pointName[3] = {"A", "B", "C"}; int i, j; int ngId = 0; for (i = 0; ; i++) { L l = L(now, now + dir); for (j = 0; j < 3; j++) { if (i == 0 && j != 1) continue; if (j == ngId) continue; if (intersectSS(l, ls[j])) { break; } } assert(j < 3); ngId = j; //次はj番目の辺を見ない P cp = crosspoint(l, ls[j]); //cout << "i = " << i << ", j = " << j << ", cp = [" << cp.real() << ", " << cp.imag() << "]" << endl; for (j = 0; j < 3; j++) { if (abs(cp - ps[j]) < EPS) { break; } } if (j < 3) { cout << pointName[j] << " " << i << endl; return 0; } P ndir; if (ngId == 0) { ndir = P(dir.real(), -dir.imag()); } else if (ngId == 2) { ndir = P(-dir.real(), dir.imag()); } else { ndir = P(-dir.imag(), -dir.real()); } now = cp; dir = ndir; //cout << "ndir = [" << ndir.real() / 4 << ", " << ndir.imag() / 4 << "]" << endl; } cout << -1 << endl; return 0; }