Cod sursa(job #1708903)

Utilizator PlayHPPet Rescue PlayHP Data 28 mai 2016 10:10:49
Problema Consecutive Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.65 kb
#include<cstdio>
#include<vector>
using namespace std;
vector<pair<int,int> > solution;
int main(){
    freopen("consecutive.in","r",stdin);
    freopen("consecutive.out","w",stdout);
    int tests,test,n,l,i;
    scanf("%d",&tests);
    for(test=1;test<=tests;test++){
        scanf("%d",&n);
        solution.clear();
        for(l=2;l*(l-1)/2<n;l++)
            if((n-l*(l-1)/2)%l==0)
                solution.push_back(make_pair((n-l*(l-1)/2)/l,(n-l*(l-1)/2)/l+l-1));
        printf("%d\n",solution.size());
        for(i=0;i<solution.size();i++)
            printf("%d %d\n",solution[i].first,solution[i].second);
    }
    return 0;
}