Cod sursa(job #2303941)
Utilizator | Data | 17 decembrie 2018 11:47:57 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
int p;
f>>p;
int fivething = 1;
int exponent = 0;
for(int i = 0; i < 16; i++){
if(fivething*5 <= p) {
fivething *= 5;
exponent++;
}
else break;
}
if(p>=5)
g<<p * 5 - 5 * ((exponent + 1) * exponent)/2;
else
g<<1;
return 0;
}