#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; typedef bitset<16> BS; struct edge { int to, cost, id; }; const ll MOD = 1E+09 + 7; const ll INF = 1E18; const int MAX_N = 2E+06; ll X; ll spf[MAX_N + 1]; //spf[i]はiの素因数のうち最小のものを示す void smallest_prime_factor(ll n); map prime_factor(ll n); ll div_count(map& mp); ll EQ[MAX_N + 1]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> X; smallest_prime_factor(X); ll res = INF; for (ll i = 1; i <= X / 2 + 1; i++) { auto a = prime_factor(i); auto b = prime_factor(X - i); ll an = div_count(a); ll bn = div_count(b); ll eq = abs(2 * i - X - an + bn); EQ[i] = eq, EQ[X - i] = eq; res = min(res, abs(2 * i - X - an + bn)); } vector

ans; for (ll i = 1; i <= X - 1; i++) { if (EQ[i] == res) { ans.push_back(P(i, X - i)); } } sort(ans.begin(), ans.end()); /* for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n"; } } */ for (auto p : ans) { cout << p.first << " " << p.second << "\n"; } return 0; } //n以下のspfを求める void smallest_prime_factor(ll n) { for (ll i = 1; i <= n; i++) { spf[i] = i; } for (ll i = 2; i * i <= n; i++) { if (spf[i] == i) { for (ll j = i * i; j <= n; j += i) { spf[j] = i; } } } } //spfを元にnを素因数分解 map prime_factor(ll n) { map res; while (n != 1) { res[spf[n]]++; n /= spf[n]; } return res; } ll div_count(map& mp) { ll res = 1; for (auto p : mp) { res *= (p.second + 1); } return res; }