Cod sursa(job #1156651)
Utilizator | Data | 27 martie 2014 20:27:57 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
//www.infoarena.ro/problema/fact
#include <fstream>
#include <iostream>
using namespace std;
int p;
long long n = 0, n_u;
ifstream in("fact.in");
ofstream out("fact.out");
int main(){
in >> p;
if (p == 0){
out << 1;
return 0;
}
while (p > 0){
n += 5;
n_u = n;
while (n_u % 5 == 0){
n_u /= 5;
p--;
}
}
out << n;
return 0;
}