Pagini recente » Cod sursa (job #1516919) | Cod sursa (job #2629829) | Cod sursa (job #2622790) | Atasamentele paginii fandoseala | Cod sursa (job #1802921)
#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;
}