# zoj 3827 Information Entropy(水题)

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int N;

double f(double x, int k) {
if (x == 0)
return 0;

if (k == 1)
return x * log2(x);
else if (k == 2)
return x * log(x);
else
return x * log10(x);
}

int main () {
int cas, k;
scanf("%d", &cas);
while (cas--) {
char op[10];
scanf("%d%s", &N, op);
if (op[0] == 'b')
k = 1;
else if (op[0] == 'n')
k = 2;
else if (op[0] == 'd')
k = 3;

int x;
double ans = 0;
for (int i = 1; i <= N; i++) {
scanf("%d", &x);
ans += f(x / 100.0, k);
}
printf("%.8lf\n", -ans);
}
return 0;
}

zoj 3827 Information Entropy(水题)

• 0

开心

• 0

板砖

• 0

感动

• 0

有用

• 0

疑问

• 0

难过

• 0

无聊

• 0

震惊

Osu! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total

Running Rabbits Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe
Problem 1021 飞船赛 Accept: 1368 Submit: 5167 Time Limit: 1000 mSec Memory Limit : 32768 KB P
Multi-bit Trie Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other
1059:table 查看 提交 统计 提问 总时间限制: 1000ms 内存限制: 65536kB 描述 Sths所在的学校里有一