Cod sursa(job #883755)
| Utilizator | Data | 20 februarie 2013 12:44:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include<fstream>
using namespace std;
ifstream fin("factorial.in");
ofstream fout("factorial.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;
}
