Cod sursa(job #1708995)

Utilizator echipa_BoSSilorUNIBUC Harsan Bicsi Baltatu echipa_BoSSilor Data 28 mai 2016 10:29:33
Problema Consecutive Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 1.34 kb
/*************************************************************\
~*********************ENJOY THE SILENCE***********************~
\*************************************************************/

#include <bits/stdc++.h>
using namespace std;

/*******************Debugging defines*************************/

#define ok_dump() cerr<<"OK\n"
#define var_dump(x) cerr<<#x": "<<x<<'\n'
#define arr_dump(x, n) {cerr<<#x"[]: ";\
	for(int _=0;_<n;++_) cerr<<x[_]<<" ";cerr<<'\n';}

/*************************************************************/

const int MAXN = 500000;
int A[MAXN], Count[MAXN], Ret[MAXN];

int main() {	
//	assert(freopen("input.txt", "r", stdin));
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ifstream fin("consecutive.in");
	ofstream fout("consecutive.out");

	int t;
	fin >> t;
	while(t--) {
		int n;
		fin >> n;

		vector<pair<int, int>> Sol;

		for(int i = 2; i <= 500000; ++i) {
			long long rez = 1LL * n - 1LL * i * (i - 1) / 2;
			if(rez <= 0) break;

			if(rez % i == 0) {
				Sol.push_back({rez / i, rez / i + i - 1});
			}
		}

		fout << Sol.size() << '\n';
		for(auto p : Sol) {
			fout << p.first << " " << p.second << '\n';
		}
	}
	
	return 0;
}

/*************************************************************\
~*********************ENJOY THE SILENCE***********************~
\*************************************************************/