Cod sursa(job #2758216)
Utilizator | Data | 8 iunie 2021 22:49:44 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<cstdio>
using namespace std;
int main()
{
FILE *f=fopen("fact.in","r"),*g=fopen("fact.out","w");
int x,facto=1,c=0,i,j;
bool gasit=false;
fscanf(f,"%i",&x);
if(x<0)
{
fprintf(g,"-1");
}
else
{
if(x==0)
{
fprintf(g,"1");
}
else
{
for(i=1;i<x*5;i*=5)
{
c++;
}
c--;
fprintf(g,"%i",x*5-c*(c-1)*5/2);
}
}
fclose(f);
fclose(g);
return 0;
}