Pagini recente » Cod sursa (job #231519) | Cod sursa (job #2008945) | Cod sursa (job #54844) | Cod sursa (job #813046) | Cod sursa (job #1709170)
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define LMax 65000
using namespace std;
vector<pair<int, int> > sol;
int Tes;
int N;
long long sum(int a, int b) {
-- b;
long long sa = 1LL * a * (a + 1) / 2;
long long sb = 1LL * b * (b + 1) / 2;
return sa - sb;
}
int main() {
freopen("consecutive.in", "r", stdin);
freopen("consecutive.out", "w", stdout);
scanf("%d", &Tes);
while ( Tes -- ) {
sol.clear();
scanf("%d", &N);
long long NN = 2LL * N;
if ( (N & ( N - 1 )) == 0 ) {
printf("0\n");
continue;
}
for ( int n = 2; 1LL * n * n <= NN; ++ n ) {
if ( NN % n == 0 ) {
int a1 = (2LL * N / n - n + 1) / 2;
int a2 = a1 + n - 1;
if ( a1 > 0 && a2 > 0 )
sol.push_back({a1, a2});
}
}
printf("%d\n", sol.size());
for ( int i = 0; i < sol.size(); ++ i )
printf("%d %d\n", sol[i].first, sol[i].second);
}
return 0;
}