Cod sursa(job #2609800)

Utilizator smitoiStefan Mitoi smitoi Data 3 mai 2020 16:10:02
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <algorithm>
// #include <chrono>

using	namespace std;
using namespace std::chrono; 

ifstream	f("fact.in");
ofstream	g("fact.out");

long int		p, v[2];
long long int	nr;
long long int aux = nr;
long long int k = 0;

int	main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	
	v[0] = 0;
	v[1] = 0;
	// auto start = high_resolution_clock::now(); 
	f >> p;
	
	for (nr = 2; v[0] < p || v[1] < p; nr++)
	{
		k = 0;
		aux = nr;
		while (aux % 5 == 0)
		{
			aux /= 5;
			k++;
		}
		v[0] += k;
		k = 0;
		aux = nr;
		while (aux % 2 == 0)
		{
			aux /= 2;
			k++;
		}
		v[1] += k;
	}

	if (v[0] > p && v[1] > p)
		g << -1;
	else
		g << nr - 1;
	
	// auto stop = high_resolution_clock::now(); 
	// auto duration = duration_cast<microseconds>(stop - start); 
	// cout << '\n' << "Time taken by function: " << duration.count() << " microseconds" << '\n'; 
	return	0;
}