Cod sursa(job #1975375)

Utilizator HumikoPostu Alexandru Humiko Data 30 aprilie 2017 17:27:29
Problema Consecutive Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.52 kb
#include <fstream>


using namespace std;

ifstream cin("consecutive.in");
ofstream cout("consecutive.out");

int a[10000], b[10000];
int main(){
long long nr, d, t, n;
cin>>t;
while(t!=0){
    cin>>nr;
    nr*=2;
    n=0;
    for (d=2;d*d<=nr;d++){
        if(nr%d==0&&nr/d%2!=d%2){
            n++;
            a[n]=(d+nr/d-1)/2-d+1;
            b[n]=(d+nr/d-1)/2;
        }
    }
    cout<<n<<'\n';
    for(d=1;d<=n;d++)
        cout<<a[d]<<' '<<b[d]<<'\n';


t--;}

 return 0;   }