Cod sursa(job #1802921)
Utilizator | Data | 10 noiembrie 2016 19:45:50 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
int n,p,c2,c5, x;
f>>p;
n = 1;
c2 = c5 = 0;
while(p > 0){
n++;
x = n;
while(x % 10 == 0){
p--;
x = x / 10;
}
while(x % 2 == 0){
c2++;
x = x / 2;
}
while(x % 5 == 0){
c5++;
x = x / 5;
}
while(c2 > 0 && c5 > 0){
c2--;
c5--;
p--;
}
}
g<< n;
return 0;
}