# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
711333 | TAhmed33 | Uzastopni (COCI17_uzastopni) | C++98 | 2 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |