Cod sursa(job #778618)
Utilizator | Data | 15 august 2012 11:14:56 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p,n = 1,d,c,x;
int main(){
in>>p;
while(p > 0)
{ x=n;
while(x % 2 == 0)
d++,x/=2;
while(x % 5 == 0)
c++,x/=5;
while(d>0 && c>0){
p--;
d--;
c--;
}
n++;
}
out<<n-1;
in.close();
out.close();
return 0;
}