Cod sursa(job #1713687)

Utilizator tudormaximTudor Maxim tudormaxim Data 6 iunie 2016 10:27:44
Problema Consecutive Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.75 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

ifstream fin ("consecutive.in");
ofstream fout ("consecutive.out");

void solve_test() {
    vector < pair <unsigned int, unsigned int> > sol;
    unsigned int n, a = 3, b = 2, c;
    fin >> n;
    while (n >= a) {
        c = (n - a) / b;
        if (c * b == n - a) {
            sol.push_back({c + 1, c + b});
        }
        b++;
        a += b;
    }
    fout << sol.size() << "\n";
    for (auto it : sol) {
        fout << it.first << " " << it.second << "\n";
    }
}

int main() {
    ios_base :: sync_with_stdio(false);
    int t;
    fin >> t;
    while (t--) {
        solve_test();
    }
    fin.close();
    fout.close();
    return 0;
}