Pagini recente » Cod sursa (job #179924) | Profil stay_awake77 | Profil stay_awake77 | Cod sursa (job #1737108) | Cod sursa (job #175026)
Cod sursa(job #175026)
#include<fstream.h>
#include<iostream.h>
#include<math.h>
int main(void)
{
fstream f,g;
long int x=1,p,temp=0,i,coun=0,temp2=1;
f.open("fact.in",ios::in);
f>>p;
f.close();
while(x<p)
x=x*5+1;
x=(x-1)/5;
g.open("fact.out",ios::out);
if(p==0)
g<<1;
else
{
if(p%6==5||p%31==30||p%156==155||p%781==780)
g<<-1;
else
{
for(i=6;i<=x;i=(i*5)+1)
{
coun++;
temp=temp+p/i;
cout<<endl<<temp;
}
g<<(p-temp+p/156)*5;
}
}
return 0;
}