Pagini recente » Cod sursa (job #3132933) | Cod sursa (job #1914719) | Borderou de evaluare (job #2051234) | Cod sursa (job #80041) | Cod sursa (job #2054107)
#include <iostream>
#include <fstream>
#include <vector>
#include <math.h>
using namespace std;
ifstream fin("consecutive.in");
ofstream fout("consecutive.out");
int n, t;
long long doubleN;
vector <pair <long long, long long> > v;
int main() {
fin >> t;
for (int i = 0; i < t; ++i) {
fin >> n;
doubleN = n * 2;
for (long long j = 1; j <= (n / 2) + 1; ++j) {
long long delta = 1 + 4 * (doubleN + j * (j - 1));
long long sqrtDelta = sqrt(delta);
if (sqrtDelta * sqrtDelta != delta)
continue;
long long x2 = (-1 + sqrtDelta) / 2;
v.push_back(make_pair(j, x2));
}
}
fout << v.size() << '\n';
for (int i = 0; i < v.size(); ++i) {
fout << v[i].first << ' ' << v[i].second << '\n';
}
return 0;
}