Pagini recente » Borderou de evaluare (job #1321511) | Monitorul de evaluare | Borderou de evaluare (job #2361142) | Cod sursa (job #895293) | Cod sursa (job #6199)
Cod sursa(job #6199)
#include<fstream.h>
#define input "fact.in"
#define output "fact.out"
int main()
{
long h,x,n;
int gr;
ifstream fin(input);
ofstream fout(output);
fin>>n;
x=n;
h=1;
gr=0;
while(h*5+1<=n)
{
h=(h*5)+1;
gr++;
}
if(n+gr>=(h*5)+1)
fout<<"-1"<<"\n";
else
{
while(h!=1)
{
x-=(x/h);
h--;
h=h/5;
}
fout<<x*5<<"\n";
}
return 0;
}