Cod sursa(job #906885)
Utilizator | Data | 7 martie 2013 12:42:54 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
int zero(int n){
int rez=0,p=5;
while(p<=n)
{
rez+=n/p;
n/=p;
}
return rez;
}
int caut(int p)
{
int i=0,pas=1<<29;
while(pas!=0)
{
if(zero(i+pas)<p)
{
i+=pas;
}
pas/=2;
}
return i+1;
}
int main()
{
ifstream in("fact.in");
ofstream out ("fact.out");
int y,p,x,cnt=0;
in>>p;
y=x=caut(p);
if(zero(x)==p){}
while(zero(x)==p)
{
x--;
}
out<<x+1;}
else out<<-1;
return 0;
}