Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- int main() {
- ll step;
- cin >> step;
- ll N = 0;
- pair<ll, ll> cord;
- while ((4 * N*N + 3 * N) < step) {
- N++;
- }
- N--;
- step = step - (4 * N*N + 3 * N);
- if (step <= N + 1) {
- cord.first = -step;
- cord.second = N;
- }
- else {
- step = step - (N + 1);
- if (step <= 2 * N + 1) {
- cord.first = -( N + 1);
- cord.second = N - step;
- }
- else {
- step = step - 2 * N - 1;
- if (step <= 2 * N + 2) {
- cord.first = step - N - 1;
- cord.second = -N - 1;
- }
- else {
- step = step - 2 * N - 2;
- if (step <= 2 * N - 1) {
- cord.first = N + 1;
- cord.second = step - N - 1;
- }
- else {
- step = step - 2 * N - 2;
- cord.first = N + 1 - step;
- cord.second = N + 1;
- }
- }
- }
- }
- cout << cord.first << endl << cord.second;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement