ZOJ 3827 Information Entropy (2014牡丹江区域赛)
题目链接:ZOJ 3827 Information Entropy
依据题目的公式算吧,那个极限是0
AC代码:
#include <stdio.h>
#include <string.h>
#include <math.h>
const double e=exp(1.0);
double find(char op[])
{
if(op[0]=='b')
return 2.0;
else if(op[0]=='n')
return e;
else if(op[0]=='d')
return 10.0;
}
int main()
{
int t,i,n;
double p[210],b;
char op[20];
scanf("%d",&t);
while(t--)
{
scanf("%d %s",&n,op);
b=find(op);
double ans=0.0;
for(i=0;i<n;i++)
{
scanf("%lf",&p[i]);
p[i]/=100.0;
if(p[i]!=0.0)
ans+=p[i]*log(p[i])/log(b);
}
printf("%.12lf\n",-ans);
}
return 0;
}
ZOJ 3827 Information Entropy (2014牡丹江区域赛)的更多相关文章
- zoj 3822 Domination(2014牡丹江区域赛D称号)
Domination Time Limit: 8 Seconds Memory Limit: 131072 KB Special Judge Edward is the headm ...
- ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)
Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...
- 2014 牡丹江现场赛 i题 (zoj 3827 Information Entropy)
I - Information Entropy Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %l ...
- ZOJ 3827 Information Entropy(数学题 牡丹江现场赛)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5381 Information Theory is one of t ...
- 2014 牡丹江区域赛 B D I
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...
- ZOJ 3827 Information Entropy 水题
Information Entropy Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/sh ...
- ZOJ 3827 Information Entropy 水
水 Information Entropy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Informati ...
- zoj 3827 Information Entropy 【水题】
Information Entropy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Information ...
- ACM学习历程——ZOJ 3829 Known Notation (2014牡丹江区域赛K题)(策略,栈)
Description Do you know reverse Polish notation (RPN)? It is a known notation in the area of mathema ...
随机推荐
- HDU 5935 Car【贪心,枚举,精度】
Problem Description Ruins is driving a car to participating in a programming contest. As on a very t ...
- 揭秘响应式web设计
0.引言 响应式web设计的作用主要使网页能在不同小大的显示窗口下依然优雅.当前的显示窗口有pc,ipad,iphone以及一些其他的设备.不同的显示窗口的分辨率各不相同,如何在不同的分辨率的情况下 ...
- n2n搭建手记-2-V2
n2n-V2搭建 [1.]在V1中遇到的问题 在完成V1搭建后,边缘节点1台机器由centos 6.5 重装为Centos 7 ,再次重加入V1时遇到 与节点其他机器 可 ping通.能通过机器的公网 ...
- 【并查集】Gym - 100923H - Por Costel and the Match
meciul.in / meciul.out Oberyn Martell and Gregor Clegane are dueling in a trial by combat. The fight ...
- 【递归】【栈】先修课 计算概论(A)/函数递归练习(2)5:布尔表达式
总时间限制: 1000ms 内存限制: 65536kB 描述 输入一个布尔表达式,请你输出它的真假值. 比如:( V | V ) & F & ( F | V ) V表示true,F表示 ...
- 【动态规划】【最短路】【spfa】bzoj1207 [HNOI2004]打鼹鼠
<法一>若打了一只鼹鼠后,还能打另一只,我们可以在它们之间连权值为1的边.于是答案就是 以m为终点的最长路长度+1.建反图,就是单源最长路. MLE TLE 一时爽. #include&l ...
- python3中zipfile模块的常用方法
一.zipfile模块的简述 zipfile是python里用来做zip格式编码的压缩和解压缩的,由于是很常见的zip格式,所以这个模块使用频率也是比较高的, 在这里对zipfile的使用方法做一些记 ...
- 如何用JavaScript重定向到另一个网页?
可以使用 window.location.replace() 方法重定向到另一个页面.相对于 window.location.href ,replace的优势是不会跳转记录并不会保留在历史会话中,这就 ...
- JAVA Socket 连接时长
其实关于这个问题可能用到的人不会很多,不过我在这里还是说说. 正常很多人写socket通信时,都会直接通过new socket(IP,PORT)直接去链接服务器.其实这种做法也没有错误,但是若当服务器 ...
- hdu2829 四边形优化dp
Lawrence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...