Cod sursa(job #2168733)
Utilizator | Data | 14 martie 2018 12:05:18 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long n, p;
int ZeroSf(int x)
{
int nr = 0;
while(x)
{
nr += x/5;
x/=5;
}
return nr;
}
int cauta(int st, int dr)
{
int mid, sol = -1;
for(int i = st;i <=dr;i++)
if(ZeroSf(i)==n)
return i;
return sol;
}
int main()
{
f>>n;
if(n!=0)
g<<cauta(0, n*5 + 5);
else g<<1;
}