Pagini recente » Cod sursa (job #2839505) | Cod sursa (job #730597) | Cod sursa (job #2705156) | Cod sursa (job #1579234) | Cod sursa (job #1709160)
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
ifstream fin("consecutive.in");
ofstream fout("consecutive.out");
struct str{int inc, sf;} aux;
long long t, n, inc, sf, sum;
vector<str> v;
bool test(str a, str b)
{
return a.sf - a.inc < b.sf - b.inc;
}
int main()
{
fin >> t;
while(t --)
{
fin >> n;
v.clear();
long long y=2;
while (y*y<=n*2+5)
{
if ((2*n+y-y*y)%(2*y)==0 && (2*n+y-y*y)/(2*y)>0)
{
aux.inc = (2*n+y-y*y)/(2*y);
aux.sf = (2*n+y-y*y)/(2*y)+y-1;
v.push_back(aux);
}
y++;
}
sort(v.begin(), v.end(), test);
fout << v.size() << '\n';
for(int i = 0; i < v.size(); i ++)
{
fout << v[i].inc << ' ' << v[i].sf << '\n';
}
}
return 0;
}