Submission #711333

#TimeUsernameProblemLanguageResultExecution timeMemory
711333TAhmed33Uzastopni (COCI17_uzastopni)C++98
80 / 80
2 ms308 KiB
#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 timeMemoryGrader output
Fetching results...