Cod sursa(job #830296)
| Utilizator | Data | 6 decembrie 2012 16:53:12 | |
|---|---|---|---|
| Problema | Factorial | Scor | 95 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int n)
{
if(n<5) return 0;
return zero(n/5)+n/5;
}
int cautare(int j,int p)
{
int i=j,pas=1<<29;
while(pas!=0)
{
if(zero(i+pas)<p)
i+=pas;
pas/=2;
}
return i+1;
}
int main()
{
int x,p;
in>>p;
x=cautare(1,p);
if(zero(x)==p)
out<<x;
else
out<<-1;
return 0;
}
