Cod sursa(job #63258)
| Utilizator | Data | 27 mai 2007 17:40:25 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<fstream.h>
ifstream f("fact.in");
ofstream g("fact.out");
void perm(unsigned long &fif, unsigned long p)
{
unsigned long sir=1;
while(sir<p)
{sir=sir*5+1;
fif-=fif/sir;}
}
int main()
{
unsigned long p,fife=0,fif;
f>>p;
if(!p)
g<<1;
else
{fif=p;fife=p+1;
perm(fif,p);
perm(fife,p+1);
if(fife!=fif)
g<<5*fif;
else
g<<-1;
}
return 0;
}