Cod sursa(job #1709042)

Utilizator TeamFIIHUAIC FIICoders TeamFIIH Data 28 mai 2016 10:41:15
Problema Consecutive Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.95 kb
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <utility>
#include <cstdio>

using namespace std;

int v[100000][2];

int main()
{
    //ios_base::sync_with_stdio(false);

    freopen("consecutive.in", "r", stdin);
    freopen("consecutive.out", "w", stdout);

    int t;
    int k = 0;
    long long n;

    scanf("%d", &t);
    while (t--){
        scanf("%d", &n);
        k = 0;
        for (long long lg = 2; (lg*(lg+1))/2 <= n; ++lg){
            long long x = n - lg*(lg+1)/2;
            if (x % lg == 0){
                v[k][0] = x/lg + 1;
                v[k][1] = x/lg + lg;
                ++k;
            }
        }
        printf("%d\n",k);
        for (unsigned i = 0; i < k; ++i){
            printf("%d %d\n",v[i][0], v[i][1]);
        }
    }

    return 0;
}