Pagini recente » Cod sursa (job #3229363) | Cod sursa (job #2544610) | Cod sursa (job #607133) | Cod sursa (job #2381964) | Cod sursa (job #1935505)
#include <fstream>
#include <vector>
#define DIM 150000
using namespace std;
ifstream f ("consecutive.in");
ofstream g ("consecutive.out");
long long n, T, nr;
pair <int, int> sol[DIM];
void solve () {
f >> n;
nr = 0;
for (int a = 2; a * a <= 2 * n; ++a) {
long long x = (2 * n / a + a - 1) / 2;
long long y = x - a;
if (x < 1 || y < 0) {
continue;
}
if (x * (x + 1) - y * (y + 1) == 2 * n) {
sol[++nr] = make_pair ((int)y + 1, (int)x);
}
}
g << nr << '\n';
for (int i = 1; i <= nr; ++i) {
g << sol[i].first << " " << sol[i].second << '\n';
}
}
int main() {
f >> T;
while (T--) {
solve ();
}
return 0;
}