套公式

Sample Input

3
3 bit
25 25 50 //百分数
7 nat
1 2 4 8 16 32 37
10 dit
10 10 10 10 10 10 10 10 10 10
Sample Output

1.500000000000
1.480810832465
1.000000000000

 # include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>
# include <queue>
# define LL long long
using namespace std ; char s[] ;
const double esp = 1e-; int main ()
{
//freopen("in.txt","r",stdin) ;
int T ;
scanf("%d" , &T) ;
while(T--)
{
int n ;
double p , b ;
scanf("%d %s" , &n , s) ;
if (s[] == 'b')
b = ;
else if (s[] == 'n')
b = exp(1.0) ;
else
b = ;
int i ;
double ans = ;
for (i = ; i < n ; i++)
{
scanf("%lf" , &p) ;
if (fabs(p) > esp)
{
p /= 100.0;
ans += p * log(p) / log(b);
} }
printf("%.12lf\n" , -ans) ; } return ;
}

zoj 3827(2014牡丹江现场赛 I题 )的更多相关文章

  1. zoj 3820(2014牡丹江现场赛B题)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5374 思路:题目的意思是求树上的两点,使得树上其余的点到其中一个点的 ...

  2. zoj 3819(2014牡丹江现场赛 A题 )

    题意:给出A班和B班的学生成绩,如果bob(A班的)在B班的话,两个班级的平均分都会涨.求bob成绩可能的最大,最小值. A班成绩平均值(不含BOB)>A班成绩平均值(含BOB) &&a ...

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

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

  4. ZOJ 3822 ( 2014牡丹江区域赛D题) (概率dp)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5376 题意:每天往n*m的棋盘上放一颗棋子,求多少天能将棋盘的每行每列都至少有 ...

  5. 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...

  6. ZOJ 2819 Average Score 牡丹江现场赛A题 水题/签到题

    ZOJ 2819 Average Score Time Limit: 2 Sec  Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge ...

  7. 2014牡丹江 现场赛 F zoj 3824 Fiber-optic Network

    首先赞一下题目, 好题 题意: Marjar University has decided to upgrade the infrastructure of school intranet by us ...

  8. zoj 3809 枚举水题 (2014牡丹江网赛 A题)

    题目大意:给出一列取样的几个山的高度点,求山峰有几个? Sample Input 291 3 2 4 6 3 2 3 151 2 3 4 5Sample Output 30 # include < ...

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

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

随机推荐

  1. Magical Girl Haze 南京网络赛2018

    题意: 就是使不大于k条路的权值变为零后求最短路 解析: d[i][j]表示使j条路变为权值后从起点到点i的最短路径 这题不能用spfa做  tle #include <iostream> ...

  2. MT【84】夹逼定值

    分析:此类题还是比较常见的,左右都有不等式,中间夹着一个式子,我们可以找个$x$使得中间式子满足的条件显示出来. 类似的方法可以用在这道浙江高考文科压轴题上

  3. Markdown公式(二)

    参考资料https://gavin_nicholas.coding.me/archives/ 1. 如何输入括号和分隔符 () . [] 和 | 表示自己, {} 表示 {} .当要显示大号的括号或分 ...

  4. 【题解】 bzoj2115: [Wc2011] Xor (线性基+dfs)

    bzoj2115,戳我戳我 Solution: 看得题解(逃,我太菜了,想不出这种做法 那么丢个链接 Attention: 板子别写错了 又写错了这次 \(long long\)是左移63位,多了会溢 ...

  5. 【hdu3842】 Machine Works

    http://acm.hdu.edu.cn/showproblem.php?pid=3842 (题目链接) 题意 一个公司使用一个厂房$D$天,希望获利最大.有$n$台机器,每一台可以在第$D_i$天 ...

  6. IO之间的比较

    在高性能的IO体系设计中,有几个名词概念常常会使我们感到迷惑不解.具体如下: 序号 问题 1 什么是同步? 2 什么是异步? 3 什么是阻塞? 4 什么是非阻塞? 5 什么是同步阻塞? 6 什么是同步 ...

  7. python中的requests使用小结

    现接触到的很少,详细的官方教程地址: requests官方指南文档:http://docs.python-requests.org/zh_CN/latest/user/quickstart.html ...

  8. element-ui合并行:span-method

    objectSpanMethod({ row, column, rowIndex, columnIndex }) { if (columnIndex === 0) { if (rowIndex % 2 ...

  9. ngx_lua_API 指令详解(三)怎样理解 cosocket指令

    参考:https://moonbingbing.gitbooks.io/openresty-best-practices/content/ngx_lua/whats_cosocket.html 春哥演 ...

  10. python 音乐下载演示源代码

    import requests import re api = 'http://music.taihe.com/search?' header = { 'User-Agent': 'Mozilla/5 ...