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