Submission #15212

#TimeUsernameProblemLanguageResultExecution timeMemory
15212hodduc맛있는 과자 (kriii3_A)C++98
33 / 33
0 ms1216 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...