Cod sursa(job #1846615)

Utilizator SpiristulTeribilStefan Vilcu SpiristulTeribil Data 13 ianuarie 2017 17:49:53
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.74 kb
#include <fstream>
#include <vector>
#include <cmath>

using namespace std ;

ifstream cin ( "input" ) ;
ofstream cout ("output") ;

const int MAX = 1e6 + 14 ;

vector < pair < int , int > > sol ;

int main ( ) 
{
	int t ; 
	cin >> t ; 
	while ( t -- ) {
		sol.clear() ;
		int n ; 
		cin >> n ; 
		int len = 2 ; 
		while ( 1LL * len * (len + 1) / 2 <= n ) {
			int aux = 1LL * len * (len + 1) / 2 ;
			int rest = n - aux ; 
			if ( rest % len == 0 ) {
				sol.push_back ( make_pair ( rest / len + 1 , rest / len + len ) ) ;
				//cout << "am bagat " << rest/len + 1 << " pentru lungimea " << len << endl ;
			}
			len += 1 ; 
		}
		cout << sol.size() << '\n' ; 
		for ( auto x : sol ) {
			cout << x.first << ' ' << x.second << '\n' ;
		}
	}
	return 0 ;
}