/* -*- coding: utf-8 -*- * * 1006.cc: No.1006 Share an Integer - 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_X = 2000000; /* typedef */ /* global variables */ int as[MAX_X]; /* subroutines */ inline int f(int n) { int c = 0; for (int p = 1; p * p <= n; p++) if (n % p == 0) c += (p * p < n) ? 2 : 1; return n - c; } /* main */ int main() { int x; scanf("%d", &x); int mind = x, m = 0; for (int a = 1; a * 2 <= x; a++) { int b = x - a; int d = abs(f(b) - f(a)); //printf("a=%d, b=%d -> d=%d\n", a, b, d); if (mind > d) { mind = d; m = 0; as[m++] = a; if (b != a) as[m++] = b; } else if (mind == d) { as[m++] = a; if (b != a) as[m++] = b; } } sort(as, as + m); for (int i = 0; i < m; i++) printf("%d %d\n", as[i], x - as[i]); return 0; }