Cod sursa(job #2074492)
Utilizator | Data | 24 noiembrie 2017 17:40:07 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream cin("fact.in");
ofstream cout("fact.out");
int fct(int n)
{
int sol=0;
while(n>0)
{
sol+=n/5;
n/=5;
}
return sol;
}
int main()
{
int n,r=0,pas=1<<30;
cin>>n;
while(pas)
{
if(fct(r+pas)<n)
r+=pas;
pas/=2;
}
if(fct(r+1)==n)
cout<<r+1;
else
cout<<-1;
return 0;
}