Mai intai trebuie sa te autentifici.
Cod sursa(job #175024)
Utilizator | Data | 9 aprilie 2008 15:10:48 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#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;
}