Cod sursa(job #1709139)

Utilizator VladTiberiuMihailescu Vlad Tiberiu VladTiberiu Data 28 mai 2016 11:01:10
Problema Consecutive Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.73 kb
#include <fstream>

#define NMax 100000
#define ll long long
using namespace std;
ifstream f("consecutive.in");
ofstream g("consecutive.out");

struct ans{
    ll prim,ultim;
}sol[NMax];

ll t,n,nr;

int main()
{
    f >> t;
    for(int count = 1; count <= t; ++count){
        f >> n;
        nr = 0;
        for(ll i = 2; 1LL*i * i<= 1LL * 2 * n;i ++){
            ll a = 1LL * (2 * n / i - i + 1) / 2;
            if(1LL*n == 1LL*(i)* (2*a + i - 1)/ 2){
                sol[++nr].prim = a;
                sol[nr].ultim = a + i - 1;
            }
        }
        g << nr << '\n';
        for(int i = 1; i <= nr; ++i){
            g << sol[i].prim << ' ' << sol[i].ultim << '\n';
        }
    }
    return 0;
}