Mai intai trebuie sa te autentifici.
Cod sursa(job #883757)
Utilizator | Data | 20 februarie 2013 12:45:54 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int i, p, v[6], y;
int main() {
fin >> p;
i = 1;
while ((v[2] < p) or (v[5] < p)) {
y = i;
if (y % 5 == 0) {
while (y % 5 == 0) {
y = y / 5;
v[5]++;
}
}
if (y % 2 == 0) {
while (y % 2 == 0) {
y = y / 2;
v[2]++;
}
}
i++;
}
if (p == 1)
fout << 0;
else
fout << i - 1;
}