Cod sursa(job #2092267)
Utilizator | Data | 21 decembrie 2017 14:48:32 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <algorithm>
#include <cmath>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main(){
int p;
long long x=0;
in>>p;
if(p==0){
out<<1;
return 0;
}
int nr=0,x2;
while(p>0){
x+=5;
x2=x;
while(x2%5==0)
--p , x2/=5;
}
if(p!=0)
out<<-1;
else
out<<x;
return 0;
}