Pagini recente » Cod sursa (job #161064) | Cod sursa (job #291854) | Cod sursa (job #2169808) | Cod sursa (job #1244743) | Cod sursa (job #991176)
Cod sursa(job #991176)
/*
#include <fstream>//varianta I 100p
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int s,i,n,m,mij,z,fact5,st,dr;
int main()
{
f>>n;st=1;dr=500000000;
while(st<=dr){
mij=(st+dr)/2;
m=mij;
z=0;fact5=5;
while(m>=fact5){z+=m/fact5;fact5*=5;}
if(z==n)break;
else if(z>n)dr=mij-1;
else st=mij+1;
}
mij=mij-mij%5;
if(n==0)g<<1<<'\n';
else
if(st<=dr) g<<mij<<'\n';
else g<<-1<<'\n';
g.close();
return 0;
}
*/
#include <fstream>//varianta II 50p
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int s,i,n,x,k;
int main()
{
f>>n;
for(i=5;i<=50000000;i+=5){
x=i;
x/=5;
k++;
while(x%5==0){x/=5;k++;}
if(k>=n)break;
}
if(n==0)g<<1<<'\n';
else
if(k==n) g<<i<<'\n';
else g<<-1<<'\n';
g.close();
return 0;
}