Cod sursa(job #1419015)
| Utilizator | Data | 14 aprilie 2015 16:33:07 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
long long cate(long long n,long long k){
long long a=0,x=1;
while(n>=k){
a+=n/k;
n/=k;
}
return a;
}
long long cautbinar(long long P){
long long r=0,pas= 1LL << 50; // 1<<x inseamna 1 pe pozitia x in reprezentarea binara
while(pas){
if( cate( r+pas , 5 ) < P ) r+=pas;
pas=pas>>1;
}
return r;
}
int main(){
long long p;
in>>p;
out<< cautbinar(p) + 1 <<'\n';
return 0;
}
