Cod sursa(job #2016524)
Utilizator | Data | 29 august 2017 16:38:50 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
int n, x, s=0;
f>>n;
if (n==0) g<<1;
else if (n==1) g<<0;
else{
x=n;
while (x%5 == 0) {
s++;
x/=5;
}
while (n%25 == 0) {
s--;
x/=25;
}
g<<s*5;
return 0;
}}