zoj 3827 Information Entropy(水题)
来源:互联网 发布:go web编程 中文pdf 编辑:程序博客网 时间:2024/06/04 19:30
题目链接:zoj 3827 Information Entropy
题目大意:三种底,计算和。
解题思路:调用库函数就可以直接算了,不过要注意Pi = 0的时候,不过它题目里居然也讲了。。。limp→0+plogb(p)=0,因为p是logp的高阶。
#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;}
0 0
- zoj 3827 Information Entropy(水题)
- zoj 3827 Information Entropy 【水题】
- ZOJ 3827 Information Entropy
- ZOJ-3827-Information Entropy
- ZOJ 3827 Information Entropy
- ZOJ-3827-Information Entropy
- ZOJ 3827 Information Entropy【水题、简单相加】
- ZOJ 3827 Information Entropy 水
- ZOJ ——3827 Information Entropy
- ZOJ Problem Set - 3827Information Entropy
- 解题报告 之 ZOJ 3827 Information Entropy
- ZOJ 3827 Information Entropy (2014牡丹江区域赛)
- ZOJ 3827 Information Entropy(数学题 牡丹江现场赛)
- zoj 3827 Information Entropy(2014牡丹江区域赛I题)
- 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-I ( ZOJ 3827 ) Information Entropy
- 信息熵 information Entropy
- Calculate Information Entropy
- 信息熵(Information Entropy)
- DEDECMS列表页随机调用多张缩略图
- JMeter基础--逻辑控制器Logic Controller
- docker命令之commit
- js跨域及解决方案
- web服务器下载.apk文件
- zoj 3827 Information Entropy(水题)
- Android与JavaScrip进行交互(二)
- 静态数据(ajax)分页
- 条件编译
- Logic Controller 逻辑控制的使用(继续中。。。)
- Python学习笔记8:标准库之正则表达式
- android的XML布局文件上使用自定义View类
- 每天一个linux命令(6):rmdir 命令
- gerrit git使用