ZOJ Problem Set - 3827Information Entropy
来源:互联网 发布:网络助手 编辑:程序博客网 时间:2024/06/05 06:10
ZOJ Problem Set - 3827Information Entropy
题目链接
题目大意:给你一个公式,然后给你n个变量x,求出这些x代入公式所得的值之和。
解题思路:普通的利用数学函数求和,只是要知道x = 0的时候,结果等于0.
代码:
#include <cstdio>#include <cstring>#include <cmath>const double esp = 1e-9;int main () { int T, n; double b, p; char str[10]; scanf ("%d", &T); while (T--) { scanf ("%d%s", &n, str); if (str[0] == 'b') b = 2; else if (str[0] == 'n') b = exp(1.0); else b = 10; double ans = 0; for (int i = 0; i < n; i++) { scanf ("%lf", &p); if (fabs(p) > esp) { p /= 100.0; ans += p * log(p) / log(b); } } printf ("%.12lf\n", -ans); }}
0 0
- ZOJ Problem Set - 3827Information 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 3827 Information 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
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- 非卡尔曼滤波融合陀螺仪和加速度计数据,kalman gyroscope accelerometer
- Sonatype Nexus 搭建Maven 私服
- 项目中oracle存储过程记录——常用语法备忘
- 查看library cache 命中率
- 快答在线 一个新的互联网产品
- ZOJ Problem Set - 3827Information Entropy
- 中断服务子程序
- Linux 下MySQL源码安装完整版
- TCP/IP详解--TCP首部选项中时间戳选项的作用
- classpath、path、JAVA_HOME的作用
- 第4卦-山水蒙-易经学习笔记
- 2014.10.13
- ubuntu命令行模式与图形界面切换
- SpringMVC接受请求参数