Cod sursa(job #1384827)
Utilizator | Data | 11 martie 2015 14:29:59 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
int zero(int n)
{
int x=0;
while(n>=5)
{
x+=n/5;
n/=5;
}
return x;
}
int fc(int p)
{
int i=0;
int pas=1<<15;
while(pas!=0)
{
if(zero(i+pas)<p)
i+=pas;
pas/=2;
}
if(zero(i+1)==p)
return i+1;
return -1;
}
int main()
{
int p;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
g<<fc(p);
return 0;
}