Cod sursa(job #1561936)
Utilizator | Data | 4 ianuarie 2016 18:06:05 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <stdio.h>
using namespace std;
FILE*f=fopen("fact.in","r");
FILE*g=fopen("fact.out","w");
int main()
{
int p,n,i=5,ok=0,x,s,z=1;
fscanf(f,"%d",&p);
while(z<p) z*=5;
i=z;
while (!ok){
x=i/5; s=0;
while (x){
s+=x;
x/=5;
}
if (s==p) {n=i; ok=1;}
i+=5;
}
fprintf(g,"%d",n);
fclose(f);
fclose(g);
return 0;
}