Pagini recente » Cod sursa (job #943692) | Statistici Riana Moga (Riana_Moga) | Cod sursa (job #2076721) | Cod sursa (job #1110048) | Cod sursa (job #2054129)
#include <fstream>
#include <queue>
#include <iostream>
using namespace std;
queue< pair<int,int> > q;
int main()
{
int n,t;
ifstream t1("consecutive.in");
ofstream t2("consecutive.out");
int i,l,a;
pair <int,int> m;
t1>>t;
for(int k=1;k<=t;k++)
{
t1>>n;
for(i=1,l=2; l*(l+1) <= 2*n ; l++ )
{
if(2*n % l ==0 )
{
if( (2*n/l -l + 1 ) % 2 ==0 )
{
a=(2*n/l + 1 -l) / 2;
if(a>0)
q.push( make_pair( a, a+l ) );
else break;
}
}
}
t2<<q.size()<<'\n';
while( !q.empty() )
{
m=q.front(); q.pop();
t2<< m.first<< ' ' << m.second<<'\n';
}
}
t1.close();
t2.close();
return 0;
}