Cod sursa(job #1703962)
Utilizator | Data | 17 mai 2016 20:38:31 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int zero(int n)
{
int nr=0;
while(n>=5)
nr+=(n/=5);
return nr;
}
int src(int rez)
{
int i=0,pas=1<<16;
while(pas!=0)
{
if(zero(i+pas)<rez)
i+=pas;
pas=pas/2;
}
i++;
if(zero(i)==rez)
return i;
return -1;
}
int main()
{
int rez;
f>>rez;
g<<src(rez);
return 0;
}