Cod sursa(job #1501220)
| Utilizator | Data | 13 octombrie 2015 06:59:38 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream o("fact.out");
int p;
inline int calc(int n){
int ct=0;
while(n){
ct+=n/5;
n/=5;
}
return ct;
}
void inline rez(){
int st = 1,dr = 100000000000,m;
while(st<=dr){
m=(st+dr)/2;
if(calc(m)<p)
st = m+1;
else
dr = m-1;
}
if(calc(st)==p)
o<<st;
else
o<<"-1";
}
int main()
{
in >> p;
rez();
return 0;
}
