Cod sursa(job #2285328)
Utilizator | Data | 18 noiembrie 2018 14:26:48 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int k,num=1,fact,n=2,ok=1;
int main()
{
f >> k;
if (k==0)
g << 1;
else {
fact=k*5;
while (ok!=0) {
for (int i=1;i<=n;i++)
num*=5;
if (num<=fact) {
fact-=5*(n-1);
n++;
num=1;
}
else
ok=0;
}
g << fact;
}
return 0;
}