Cod sursa(job #2059454)

Utilizator vvvictorvictor vvvictor Data 7 noiembrie 2017 01:14:00
Problema Consecutive Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.7 kb
#include <bits/stdc++.h>
typedef unsigned long long ull;
using namespace std;
vector< pair<ull, ull> > sol;

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

ull go(ull N)
{
    ull count = 0;
    for (ull L = 1; L * (L + 1) < 2 * N; L++)
    {
        float a = (1.0 * N - (L * (L + 1)) / 2) / (L + 1);
        if (a - (ull)a == 0.0) 
        {
        	sol.push_back({a, a + L});
        	count++;
        }           
    }

    return count;
}
 
int main()
{
    int t;
    fin >> t;

    while (t--)
    {
    	ull n;
    	fin >> n;
    	sol.clear();

    	fout << go(n) << endl;
    	for (auto e : sol)
    	{
    		fout << e.first << " " << e.second << endl;
    	}
    }
    return 0;
}