Cod sursa(job #3358975)

Utilizator gigeldannustiu gigeldan Data 22 iunie 2026 18:17:48
Problema Consecutive Scor 100
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.72 kb
#include <bits/stdc++.h>

using namespace std;
ifstream ci("consecutive.in");
ofstream cou("consecutive.out");
void rez() {
    long long n;
    ci >> n;
    vector<pair<long long, long long>> solutii;
    for (long long k=2;k*(k-1)/2< n; k++) {
        long long gaus=k*(k-1)/2;
        if ((n-gaus)%k == 0){
            long long a=(n-gaus)/k;
            long long b=a+k-1;
            solutii.push_back({a, b});
        }
    }
    cou << solutii.size() << "\n";
    for (const auto& p : solutii) {
        cou << p.first << " " << p.second << "\n";
    }
}
int t;
int main() {
    ios_base::sync_with_stdio(false);
    ci.tie(NULL);
    ci >> t;
    while (t--) {
        rez();
    }

    return 0;
}