Cod sursa(job #2157825)

Utilizator HumikoPostu Alexandru Humiko Data 9 martie 2018 22:39:42
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.62 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin ("consecutive.in");
ofstream fout ("consecutive.out");

pair <int, int> v[10000];
int t;
long long n, pos;

int main()
{
    ios::sync_with_stdio(false);
    fin.tie(0); fout.tie(0);
    fin>>t;
    while ( t-- )
    {
        fin>>n;
        long long x = n*2;
        for ( long long i = 2; i*i <= x; ++i )
            if ( x%i == 0 && x/i%2 != i%2 )
                v[++pos] = make_pair((i+x/i-1)/2-i+1, (i+x/i-1)/2);
        fout<<pos<<'\n';
        for ( int i = 1; i <= pos; ++i )
            fout<<v[i].first<<" "<<v[i].second<<'\n';
    }
}