#include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; using Vl = vector; void merge_sort(Vl& X, const Vl& Y, int l, int r) { //cout << l << ' ' << r << endl; if (l == r - 1 || l == r) { return; } merge_sort(X, Y, l, (l + r) / 2); merge_sort(X, Y, (l + r) / 2, r); int p = l; int q = (l + r) / 2; Vl Q(r - l); for (int i = l; i < r; i++) { if (p == (l + r) / 2) { Q[i - l] = X[q]; q++; continue; } if (q == r) { Q[i - l] = X[p]; p++; continue; } ll& a = X[p]; ll& b = X[q]; if ((a < b) == (((Y[(int)b] - Y[(int)a]) * (Y[(int)b] - Y[(int)a])) < (2ll * (b - a) * (b - a)))) { Q[i - l] = a; p++; } else { Q[i - l] = b; q++; } } for (int i = l; i < r; i++) { X[i] = Q[i - l]; } } int main() { ll cnt = 0; ll pk = 1; double s2 = 1.41421356; ll N; cin >> N; /*for (ll i = 0; i <= 1159; i++) { calc2(1158, i); calc2(1159, i); calc2(i, 1158); calc2(i, 1159); } return 0;*/ while (true) { ll kj = pk / s2; while (kj > 0 && kj * kj * 2 >= pk * pk) { kj--; } while (kj * kj * 2 <= pk * pk) { kj++; } cnt += kj; if (cnt >= N) { break; } pk++; } //cout << "end " << pk << endl; Vl X; Vl Y; vector> Z; ll now = 0; for (ll i = 0; i * i * 2 <= pk * pk; i++) { while (now * now <= i * i * 2) { now++; } now--; Y.push_back(now); X.push_back(i); Z.push_back(make_pair(sqrt(2) * i - now, i)); } ll kj = X.size(); merge_sort(X, Y, 0, kj); ll ans2 = X[static_cast(N + kj - cnt - 1)]; ll ans1 = Y[static_cast(ans2)] + 1; cout << pk - ans1 << ' ' << ans2 << endl; }