#include<stdio.h>
#include<cmath>
#include<algorithm>
int a,b,n;
long long k;
long long pyt[50][50];
double base, lna, lnb, lnc;
struct L {
double val;
long long cnt;
}ll[50];
bool acomp(L a, L b) {
return a.val < b.val;
}
int main()
{
pyt[0][0] = 1;
for(int i=1;i<41;i++){
pyt[i][0]=1;
pyt[i][i]=1;
for(int j=1;j<i;j++) pyt[i][j]=pyt[i-1][j]+pyt[i-1][j-1];
}
scanf("%d %d %d %lld", &a, &b, &n, &k);
lna = log(a)*2;
lnb = log(b)*2;
lnc = log(a*a+b*b);
base = log(a*b) - log(2) - n*lnc;
long long tmp = 1; tmp <<= n;
k = tmp + 1 - k;
for(int i = 0; i <= n; i++)
{
ll[i].val = lna*i + lnb*(n-i);
ll[i].cnt = pyt[n][i];
}
int L = n+1;
std::sort(ll, ll+L, acomp);
long long v = 0;
// for(int i = 0; i < L; i++){
// printf("%lld %.12lf\n", ll[i].cnt, ll[i].val+base);
// }
for(int i = 0; i < L; i++){
v += ll[i].cnt;
if (v >= k){
printf("%.12lf\n", ll[i].val+base);
break;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1216 KB |
Output is correct |
2 |
Correct |
0 ms |
1216 KB |
Output is correct |
3 |
Correct |
0 ms |
1216 KB |
Output is correct |
4 |
Correct |
0 ms |
1216 KB |
Output is correct |
5 |
Correct |
0 ms |
1216 KB |
Output is correct |
6 |
Correct |
0 ms |
1216 KB |
Output is correct |
7 |
Correct |
0 ms |
1216 KB |
Output is correct |
8 |
Correct |
0 ms |
1216 KB |
Output is correct |
9 |
Correct |
0 ms |
1216 KB |
Output is correct |
10 |
Correct |
0 ms |
1216 KB |
Output is correct |
11 |
Correct |
0 ms |
1216 KB |
Output is correct |
12 |
Correct |
0 ms |
1216 KB |
Output is correct |
13 |
Correct |
0 ms |
1216 KB |
Output is correct |
14 |
Correct |
0 ms |
1216 KB |
Output is correct |
15 |
Correct |
0 ms |
1216 KB |
Output is correct |
16 |
Correct |
0 ms |
1216 KB |
Output is correct |
17 |
Correct |
0 ms |
1216 KB |
Output is correct |
18 |
Correct |
0 ms |
1216 KB |
Output is correct |
19 |
Correct |
0 ms |
1216 KB |
Output is correct |
20 |
Correct |
0 ms |
1216 KB |
Output is correct |
21 |
Correct |
0 ms |
1216 KB |
Output is correct |
22 |
Correct |
0 ms |
1216 KB |
Output is correct |
23 |
Correct |
0 ms |
1216 KB |
Output is correct |
24 |
Correct |
0 ms |
1216 KB |
Output is correct |
25 |
Correct |
0 ms |
1216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1216 KB |
Output is correct |
2 |
Correct |
0 ms |
1216 KB |
Output is correct |
3 |
Correct |
0 ms |
1216 KB |
Output is correct |
4 |
Correct |
0 ms |
1216 KB |
Output is correct |
5 |
Correct |
0 ms |
1216 KB |
Output is correct |
6 |
Correct |
0 ms |
1216 KB |
Output is correct |
7 |
Correct |
0 ms |
1216 KB |
Output is correct |
8 |
Correct |
0 ms |
1216 KB |
Output is correct |
9 |
Correct |
0 ms |
1216 KB |
Output is correct |
10 |
Correct |
0 ms |
1216 KB |
Output is correct |
11 |
Correct |
0 ms |
1216 KB |
Output is correct |
12 |
Correct |
0 ms |
1216 KB |
Output is correct |
13 |
Correct |
0 ms |
1216 KB |
Output is correct |
14 |
Correct |
0 ms |
1216 KB |
Output is correct |
15 |
Correct |
0 ms |
1216 KB |
Output is correct |
16 |
Correct |
0 ms |
1216 KB |
Output is correct |
17 |
Correct |
0 ms |
1216 KB |
Output is correct |
18 |
Correct |
0 ms |
1216 KB |
Output is correct |
19 |
Correct |
0 ms |
1216 KB |
Output is correct |
20 |
Correct |
0 ms |
1216 KB |
Output is correct |
21 |
Correct |
0 ms |
1216 KB |
Output is correct |
22 |
Correct |
0 ms |
1216 KB |
Output is correct |
23 |
Correct |
0 ms |
1216 KB |
Output is correct |
24 |
Correct |
0 ms |
1216 KB |
Output is correct |
25 |
Correct |
0 ms |
1216 KB |
Output is correct |