Cod sursa(job #1708916)

Utilizator TeamFIIBUAIC NoReturnValue TeamFIIB Data 28 mai 2016 10:13:56
Problema Consecutive Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.64 kb
#include <iostream>
#include<vector>
#include<fstream>
#include<utility>
using namespace std;

long long x, l;
vector< pair<int, int> > sol;

int main() {

	ifstream cin("consecutive.in");
	ofstream cout("consecutive.out");
	
	int t;
	cin>>t;
	
	for (; t; --t) {
		
		cin>>x;
		sol.clear();
		
		for (l=2; l*(l+(long long)1)/(long long)2<=x; ++l) {
			long long aux=x-l*(l-(long long)1)/(long long)2;
			
			if (aux%l==0) {
				sol.push_back(make_pair(aux/l,aux/l+l-1));
			}
			
		}
		
		cout<<sol.size()<<"\n";
		for (int i=0; i<sol.size(); ++i) cout<<sol[i].first<<" "<<sol[i].second<<"\n";
		
		
	}

	return 0;
}