Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cmath>
- #include <iostream>
- #include <map>
- #include <set>
- #include <string>
- #include <tuple>
- #include <unordered_map>
- #include <unordered_set>
- #include <vector>
- typedef long long ll;
- using namespace std;
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- ll n = 0;
- cin >> n;
- --n;
- ll s = sqrt(n);
- // Требуется проверить на точность вычисления.
- if ((s + 1) * (s + 1) <= n) ++s;
- else if (s * s > n) --s;
- n -= s * s;
- if (s % 2 == 1) {
- if (n <= s) cout << n + 1 << " " << s + 1 << endl;
- else cout << s + 1 << " " << s - (n - s) + 1 << endl;
- } else {
- if (n <= s) cout << s + 1 << " " << n + 1 << endl;
- else cout << s - (n - s) + 1 << " " << s + 1 << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement