Mai intai trebuie sa te autentifici.
Cod sursa(job #36039)
| Utilizator | Data | 22 martie 2007 21:17:05 | |
|---|---|---|---|
| Problema | Factorial | Scor | 35 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <stdio.h>
FILE *f;
long a[11],i,j,n,s;
int main()
{f=fopen("fact.in","r");fscanf(f,"%ld",&n);fclose(f);
a[1]=5;a[2]=25;a[3]=125;a[4]=625;a[5]=3125;a[6]=15625;a[7]=78125;
a[8]=390625;a[9]=1953125;a[10]=9765625;
while(s<n)
{i+=5;for(j=1;j<=10;j++)if(i%a[j]!=0)break;j--;
s+=j;
}
if(n==0)i=1;
f=fopen("fact.out","w");
if(s==n)fprintf(f,"%ld",i);else fprintf(f,"-1");
fclose(f);
return 0;
}