Cod sursa(job #1706592)
| Utilizator | Data | 22 mai 2016 21:00:06 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <iostream>
#include<fstream>
#include<climits>
using namespace std;
long long p,u,m,key;
long long zeros(long long x)
{
long long nr=0;
if(x==0) return -1;
while(x!=0)
{
x/=5;
nr+=x;
}
return nr;
}
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>key;
p=0;u=LLONG_MAX;
while(u-p>1)
{
m=(p+u)/2;
if(zeros(m)<key) p=m;
else u=m;
}
if(zeros(u)==key)g<<u;
else g<<'-1';
return 0;
}
