Cod sursa(job #3302335)

Utilizator iccjocIoan CHELARU iccjoc Data 6 iulie 2025 16:00:47
Problema Consecutive Scor 0
Compilator cpp-64 Status done
Runda Arhiva ICPC Marime 0.8 kb
#include <bits/stdc++.h>
using namespace std;

int main()
{
    freopen("consecutive.in", "r", stdin);
    freopen("consecutive.out", "w", stdout);
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int sn = sqrt((n << 1)), cnt = 0;
        vector<int> st, dr;
        for(int i = 2; i <= sn; i++)
        {
            if((n << 1) % i == 0 && (((n << 1) / i - i) & 1))
            {
                cnt++;
                st.push_back(((n << 1) / i - i + 1) >> 1);
                dr.push_back((((n << 1) / i - i + 1) >> 1) + i - 1);
            }
        }
        cout << cnt << "\n";
        for(int i = 0; i < cnt; i++)
        {
            cout << st[i] << " " << dr[i] << "\n";
        }
    }
}