Cod sursa(job #2178405)
Utilizator | Data | 19 martie 2018 14:18:21 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.3 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
long long p,po=5,s;
fin>>p;
if(p%10==5 && p!=0) {fout<<"-1";return 0;}
s=p*5;
while(po<=p){
s-=po;
po*=5;
}
fout<<s;
return 0;
}