Cod sursa(job #2779738)
Utilizator | Data | 4 octombrie 2021 19:53:38 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
long long x,s=0,i=0,j,s1=0;
f>>x;
if(x==0)
g<<1;
else
{
s=x*5-5*((x-1)/5);
for(j=5;j<=500000000;j*=5)
s1+=s/j;
if(s1>39 && s1%10!=0 && s1%10!=5)
s1+=5;
if(x==s1)
g<<s;
else
g<<"-1 ";
}
}