#include #include #include FILE *input; int x [200000], y [200000]; int a; void init () { int d = 0, e = 1; int k = 0, l = 1, b = 0; x [1] = 0; y [1] = 0; x [2] = 0; y [2] = 1; for (int i = 3; i <= 100000; i++) { switch (k) { case 0: d--; break; case 1: e--; break; case 2: d++; e--; break; case 3: d++; break; case 4: e++; break; case 5: d--; e++; break; } x [i] = d; y[i]=e; // printf ("%d %d %d %d %d\n", d, e, b, k, l); b++; if (b == l) { k++; b = 0; } if (k == 5 && b == 0) { e++; i++; x [i] = d; y [i] = e; } else if (k == 6) { // e++; k = 0; l++; } } } int read_case () { fscanf (input, "%d", &a); if (feof (input)) return 0; return 1; } void solve_case () { printf ("%d %d\n", x [a], y[a]); } int main () { init (); input = fopen ("bee.in", "r"); assert (input != NULL); while (read_case ()) solve_case (); fclose (input); return 0; }