Cod sursa(job #3302415)

Utilizator Iustin_Mircea2010Iustin Mircea Iustin_Mircea2010 Data 7 iulie 2025 14:03:16
Problema Consecutive Scor 0
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.65 kb
#include <bits/stdc++.h>
#define int long long
using namespace std;

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

void solve(){
    
    int n;
    fion >> n;
    vector<pair<int, int>> ans;
    for(int p = 2; p * (p + 1) <= 2 * n; p++){
        if((2 * n) % p == 0){
            int k = (2 * n) / p;
            k -= (p + 1);
            if(k % 2 == 0){
                ans.push_back({k / 2 + 1, k / 2 + p});
            }
        }
    }
    fout << ans.size() << '\n';
    for(auto [x, y] : ans){
        fout << x << " " << y << '\n';
    }
}

signed main(){
    
    int t;
    fin >> t;
    while(t--) solve();
    
    return 0;
    
}