Cod sursa(job #1708979)

Utilizator UNIBUC_Echipa_LachetaBicsi Nitu Velea UNIBUC_Echipa_Lacheta Data 28 mai 2016 10:26:15
Problema Consecutive Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 1.43 kb
#include <cassert>
#include <fstream>
#include <cstring>
#include <queue>
#include <algorithm>
#include <bitset>
#include <ctime>
#include <set>
#include <cmath>
#include <iomanip>
#include <map>
#include <stack>
#include <vector>
#include <bitset>

#include <fstream>

using namespace std;

#define FOR(i, a, n) for (int i = a; i <= n; ++i)
#define ROF(i, n, a) for (int i = n; i >= a; i--)
#define FIT(i, v) for (auto &i : v)
#define pb push_back
#define mp make_pair
#define mt make_touple
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000009;
ll powmod(ll a, ll b) {ll res=1; a %= mod; assert(b >= 0); for(; b; b >>= 1) {if (b & 1) res = res * a % mod; a = a * a % mod;} return res;}

const int N = 100005;

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

int main() {
    int T;
    fin >> T;
    while (T--) {
        long long x;
        fin >> x;
        vector<pair<int,int> > sol;
        
        for (int k = 2; k * k - k <= 2*x; ++k) {
            long long n = (2 * x - k * k + k);
            if (n % (2*k) != 0)
                continue;
            n /= 2*k;
            if (n != 0)
                sol.push_back({n, n+k-1});
        }
        fout << sol.size() << "\n";
        for (auto &el : sol) {
            fout << el.first << " " << el.second << "\n";
        }
    }
    
    return 0;
}