Submission #711333

# Submission time Handle Problem Language Result Execution time Memory
711333 2023-03-16T15:26:13 Z TAhmed33 Uzastopni (COCI17_uzastopni) C++
80 / 80
2 ms 308 KB
#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
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 2 ms 212 KB Output is correct