Cod sursa(job #1464437)
Utilizator | Data | 23 iulie 2015 15:44:28 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
main()
{
ifstream f1("fact.in");
ofstream f2("fact.out");
int n=0, p, pow2=0, pow5=0;
f1>>p;
while (min(pow2,pow5) < p)
{
n++;
while (n%2 == 0){
n = n / 2;
pow2++;
}
while (n % 5 == 0){
n = n / 5;
pow5++;
}
}
f2<<n;
}