Cod sursa(job #2078573)
Utilizator | albu alex syndicat3 | Data | 29 noiembrie 2017 19:01:19 |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
int zero(int n)
{
int nro=0;
while (n>=5)
{
nro+=(n/=5);
}
return nro;
}
int main()
{
ifstream in("fact.in");
ofstream out("fact.out");
long long p,r,pas;
in>>p;
r=0;
pas=1<<28;
while (pas!=0)
{
if (zero(r+pas)<p)
{
r+=pas;
}
pas/=2;
}
r++;
if (zero(r)!=p) r=-1;
out<<r;
in.close();
out.close();
return 0;
}