# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
711333 | TAhmed33 | Uzastopni (COCI17_uzastopni) | C++98 | 2 ms | 308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main () {
int n;
cin >> n;
//j(j + 1) / 2 - i(i -1) / 2 = n
//j(j + 1) - i(i - 1) = 2n
//j^2 + j - i^2 + i = 2n
//j^2 - i^2 + j + i = 2n
//(j + i)(j - i) + (j + i)(1) = 2n
//(j + i)(j - i + 1) = 2n
/*
j + i = p
q--;
j - i = q
2j = p + q
j = (p + q)/2
i = (p - q) / 2;
*/
n *= 2;
for (int i = 1; i * i < n; i++) {
if (n % i) continue;
int q = i;
int p = n/i;
if (p < q) swap(p, q);
q--;
if (!q) continue;
if ((p + q) & 1) continue;
int x = (p + q) / 2;
int y = (p - q) / 2;
cout << y << " " << x << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |