Cod sursa(job #1253336)
Utilizator | Data | 1 noiembrie 2014 09:35:29 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream>
using namespace std;
fstream in ("fact.in" , ios::in ),
out("fact.out", ios::out);
int p;
int zero(int x);
int main(){
in >> p;
long long pas = 1LL<<50LL, i=0;
while( pas ){
if( zero( pas+i ) < p ){
i+=pas;
}
pas/=2;
}
out << i+1 <<'\n';
return 0;
}
int zero(int x){
int rez = 0;
while( x>=5 ){
rez += x/5;
x /= 5;
}
return rez;
}