Cod sursa(job #644074)
Utilizator | Data | 5 decembrie 2011 09:54:42 | |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include<cstdio>
using namespace std;
int main()
{FILE*f=fopen("fact.in","r");
FILE*g=fopen("fact.out","w");
int n,p,s=0,p1,ok=0,k=2;
fscanf(f,"%d",&p);
n=p*5;
int x=p;
while(s!=x){
s=0;
p1=5;
while(n/p1!=0){
s=s+(n/p1);
p1=p1*5;
}
p--;
n=p*5;
ok=1;
}
if(ok==1)
fprintf(g,"%d",(p+1)*5);
if(ok==0)
fprintf(g,"1");
}