返回题解分享
讨论 / 题解分享/ 帖子详情

01 串的熵(结果填空) - 题解

#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
    int n = 23333333 / 2;
    int m = n + 1;
    int q = 23333333;

    int i;
    for(i = n; i >= 0; i -- )
    {
        double a0 = -1 * 1.0 * i * (1.0 * i / q) * log2(1.0 * i / q);
        double a1 = -1 * 1.0 * (q - i) * (1.0 * (q - i) / q) * log2(1.0 * (q - i) / q);
        double aa = a0 + a1;
        if(fabs(aa - 11625907.5798) < 0.0001)
            break;
    }
    cout << i;
}
0 回复 0 转发 0 喜欢 2 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!