Cod sursa(job #1710552)

Utilizator lucametehauDart Monkey lucametehau Data 29 mai 2016 11:47:25
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.58 kb
#include <fstream>

using namespace std;
ifstream cin("consecutive.in");
ofstream cout("consecutive.out");
int a[5000],b[5000];
int main()
{
    long long n,i,d,t,x;
    cin>>t;
    for(i=1;i<=t;i++)
    {
        cin>>n;
        n*=2;
        x=0;
        for(d=2;d*d<=n;d++)
        {
            if(n%d==0&&n/d%2!=d%2)
            {
                x++;
                a[x]=(d+n/d-1)/2-d+1;
                b[x]=(d+n/d-1)/2;
            }
        }
        cout<<x<<'\n';
        for(d=x;d>=1;d--)
            cout<<a[d]<<' '<<b[d]<<'\n';
    }
    return 0;
}