Pagini recente » Cod sursa (job #2946506) | Cod sursa (job #2680777) | Cod sursa (job #980771) | Cod sursa (job #2693711) | Cod sursa (job #1975414)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <stack>
using namespace std;
ifstream f("consecutive.in");
ofstream g("consecutive.out");
int T;
long int N,p,q;
int i,ct=0;
stack<long> s;
int main()
{
f>>T;
for (i=1; i<=T; i++)
{
f>>N;
if((N&(N-1)) == 0)
{
g<<0<<endl;
}
else
{
for(p = N/2; p>=2; p--)
{
if (2*N%p== 0)
{
if((2*N/p-p)%2 == 1)
{
s.push(p);
ct++;
}
}
}
g<<ct<<endl;
ct=0;
while(!s.empty())
{
p=s.top();
s.pop();
g<<(2*N/p-p+1)/2<<" "<<(2*N/p-p+1)/2+p-1<<endl;
}
}
}
}