Cod sursa(job #1477457)
Utilizator | Data | 26 august 2015 12:52:29 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream in;
ofstream out;
int main() {
bool a = true;
long int P, nr2=0, nr5=0;
long long int N=0, n;
in.open("fact.in");
in >> P;
in.close();
while (a)
{
N++;
n = N;
while (n % 2 == 0)
{
nr2++;
n /= 2;
}
while (n % 5 == 0)
{
nr5++;
n /= 5;
}
if (min(nr2, nr5) >= P)
{
a = false;
}
}
out.open("fact.out");
out << N;
out.close();
}