Cod sursa(job #1703964)
Utilizator | Data | 17 mai 2016 20:39:42 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
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<<30;
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;
}