Cod sursa(job #1708898)

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

int nrt, n;

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

    scanf("%d", &nrt);

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

        vector < pair<int, int> > sol;
        for(int lg = 2; 1LL * 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;
}