Cod sursa(job #1708908)

Utilizator team_nameUPB Banu Popa Visan team_name Data 28 mai 2016 10:12:52
Problema Consecutive Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.68 kb
#include <cstdio>
#include <vector>
using namespace std;

int nrt;
long long n;

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

    scanf("%d", &nrt);

    while(nrt--) {
        scanf("%lld", &n);

        vector < pair<int, int> > sol;
        for(long long lg = 2; lg * (lg + 1) / 2 <= n; ++lg) {
            if((2 * n - (lg - 1) * lg )% (2 * lg) == 0) {
                int a = (2 * n - (lg - 1) * lg) / (2*lg);
                sol.push_back(make_pair(a, a + lg - 1));
            }
        }

        printf("%d\n", (int) sol.size());
        for(auto x: sol)
            printf("%d %d\n", x.first, x.second);
    }


    return 0;
}