# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1260701 | wedonttalkanymore | Uzastopni (COCI17_uzastopni) | C++20 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 16;
int n;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
cin >> n;
int t = 2 * n;
for (int j = 2; j * j <= t; j++) {
if (t % j == 0) {
int val1 = j;
int val2 = t / j;
val1--;
if (!val1) continue;
// cout << val1 << ' ' << val2 << ' ';
int L = (val2 - val1) / 2;
int R = (val1 + val2) / 2;
if ((R + L) * (R - L + 1) / 2 != n) continue;
// if (((R * (R + 1)) / 2) - ((L * (L - 1)) / 2) == n) continue;
cout << L << ' ' << R << '\n';
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |