Cod sursa(job #1707319)
Utilizator | Data | 24 mai 2016 20:10:16 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
using namespace std;
const int pas=1<<27;
int zero(int n)
{
int x=0;
while(n>=5)
{
x+=n/5;
n/=5;
}
return x;
}
int main()
{
int n,p,i,y;
cin>>p;
y=pas;
i=0;
while(y!=0)
{
if(zero(i+y)<p)
i+=y;
y/=2;
}
i++;
if(zero(i)==p)
cout<<i;
else
cout<<-1;
return 0;
}