Cod sursa(job #908243)
Utilizator | Data | 8 martie 2013 22:04:37 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<stdio.h>
using namespace std;
long int p,i=1,s,putere,x;
int main()
{
FILE*f=fopen("fact.in","r");
FILE*g=fopen("fact.out","w");
fscanf(f,"%d",&p);
while(s<p)
{ if(i==1) i=i+4;
else i=i+5;
putere=0;x=i;
while((x>1)&&(x%5==0))
{
putere++;x=x/5;
}
s=s+putere;
}
if(s==p) fprintf(g,"%d",i);
else fprintf(g,"-1");
fclose(f);
fclose(g);
return 0;
}