题目链接: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牡丹江区域赛)的更多相关文章

  1. zoj 3822 Domination(2014牡丹江区域赛D称号)

    Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headm ...

  2. ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)

    Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...

  3. 2014 牡丹江现场赛 i题 (zoj 3827 Information Entropy)

    I - Information Entropy Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %l ...

  4. ZOJ 3827 Information Entropy(数学题 牡丹江现场赛)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=5381 Information Theory is one of t ...

  5. 2014 牡丹江区域赛 B D I

    http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=358 The 2014 ACM-ICPC Asia Mudanj ...

  6. ZOJ 3827 Information Entropy 水题

    Information Entropy Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/sh ...

  7. ZOJ 3827 Information Entropy 水

    水 Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Informati ...

  8. zoj 3827 Information Entropy 【水题】

    Information Entropy Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Information ...

  9. 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 ...

随机推荐

  1. CF984 C. Finite or not?【数论/GCD】

    [链接]:CF [题意]:n组样例,对于每组样例,给你三个数p q b,问你p/q在b进制下是不是一个有限小数,是的话输出Finite,否则输出Infinite. [分析]:b的过程是对q约分,那么只 ...

  2. 并查集【CF731C】Socks

    Description 有\(n\)只袜子,\(k\)种颜色,在\(m\)天中,问最少修改几只袜子的颜色,可以使每天要穿的袜子颜色相同. Input 第一行\(n,m,k\)分别对应题目描述. 接下来 ...

  3. 树状数组【CF703D】Mishka and Interesting sum

    Description 给你n( 1<=n<=1000000)个数,以及m(1<=m<=1000000)个询问,每个询问包括l和r,问你在这n个数中,区间l~r,出现偶数个数的 ...

  4. AOJ 2230 How to Create a Good Game(费用流)

    [题目链接] http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2230 [题目大意] 给出一张图,从1到n的最长路不变的情况下, 还能 ...

  5. 【kruscal】【最小生成树】【离线】洛谷 P2266 爱的距离

    建图:每个点向它四周的点连边权为两点点权的差的绝对值的边. 由于有多个需要“施法”的点,所以相当于对每个这样的点,询问与它的距离在T以内的最长边的最小值,即多次询问. 最长边最小之类的,肯定是最小生成 ...

  6. Exercise01_07

    public class Outcome{ public static void main(String[] args){ double x, y; x=4*(1.0-1.0/3+1.0/5-1.0/ ...

  7. 使用shell生成随机数

    #!/bin/bash $` do $` do s=$(($RANDOM%)) done done 第1行:#!/bin/bash是指此脚本使用/bin/bash来解释执行.其中,#!是一个特殊的表示 ...

  8. golang技巧-接口型函数

    接口型函数:指的是用函数实现接口,这样在调用的时候就会非常简便,这种函数为接口型函数,这种方式适用于只有一个函数的接口. 定义一个类型,这个类型只定义了函数的参数列表,函数参数列表与接口定义的方法一致 ...

  9. 如何在debug模式下,使用正式的签名文件

    有两种方式(在集成第三方库的使用 使用的非常多)  签名配置信息 一是直接按F4,在项目结构面板中进行设置,只要操作两个两个选项卡就好了,signing(生成配置信息)和build types(打包类 ...

  10. 谁说 JavaScript 很简单了?

    转载请注明出处,保留原文链接以及作者信息 本文介绍了 JavaScript 初学者应该知道的一些技巧和陷阱.如果你是老司机,就当做回顾了,哪里有写的不好的地方欢迎指出. 1. 你是否尝试过对一个数字数 ...