Cod sursa(job #806286)
| Utilizator | Data | 2 noiembrie 2012 15:44:43 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<fstream>
#include<iostream>
using namespace std;
int zero(int n)
{
int contor=0;
while(n>=5)
{
contor += n/5;
n/=5;
}
return contor;
}
int caut(int p)
{
int i=0,pas=1<<30;
while(pas!=0)
{
if(zero(i+pas)<p)
i+=pas;
pas /= 2;
}
return i+1;
}
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
int n,p;
in>>p;
n = caut(p);
if(zero(n)==p)
out<<n;
else
out<<"-1";
in.close();
out.close();
}
