码迷,mamicode.com
首页 > 其他好文 > 详细

The 2014 ACM-ICPC Asia Mudanjiang Regional

时间:2014-10-30 09:21:33      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   color   os   ar   for   

继续复盘之前的Regional......

 

【A】签到题

【B】树结构,树的中心

【C】-_-///

【D】概率DP

【E】-_-///

【F】树结构填数

【G】-_-///

【H】模拟

【I】签到题

【J】-_-///

【K】贪心,构造后缀表达式

 

 

 

【A】 ZOJ 3819

Average Score

Time Limit: 2 Seconds                                     Memory Limit: 65536 KB                            

Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mathematical Analysis.

After a mid-term exam, Bob was anxious about his grade. He went to the professor asking about the result of the exam. The professor said:

"Too bad! You made me so disappointed."

"Hummm... I am giving lessons to two classes. If you were in the other class, the average scores of both classes will increase."

Now, you are given the scores of all students in the two classes, except for the Bob‘s. Please calculate the possible range of Bob‘s score. All scores shall be integers within [0, 100].

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains two integers N (2 <= N <= 50) and M (1 <= M <= 50) indicating the number of students in Bob‘s class and the number of students in the other class respectively.

The next line contains N - 1 integers A1, A2, .., AN-1 representing the scores of other students in Bob‘s class.

The last line contains M integers B1, B2, .., BM representing the scores of students in the other class.

Output

For each test case, output two integers representing the minimal possible score and the maximal possible score of Bob.

It is guaranteed that the solution always exists.

Sample Input

2
4 3
5 5 5
4 4 3
6 5
5 5 4 5 3
1 3 2 2 1

Sample Output

4 4
2 4

【分析】

签到,写个方程稍微推一下即可得到区间

 

【I】 ZOJ 3827

Information Entropy

Time Limit: 2 Seconds                                     Memory Limit: 65536 KB                                                     Special Judge                            

Information Theory is one of the most popular courses in Marjar University. In this course, there is an important chapter about information entropy.

Entropy is the average amount of information contained in each message received. Here, a message stands for an event, or a sample or a character drawn from a distribution or a data stream. Entropy thus characterizes our uncertainty about our source of information. The source is also characterized by the probability distribution of the samples drawn from it. The idea here is that the less likely an event is, the more information it provides when it occurs. 

Generally, "entropy" stands for "disorder" or uncertainty. The entropy we talk about here was introduced by Claude E. Shannon in his 1948 paper "A Mathematical Theory of Communication". We also call it Shannon entropy or information entropy to distinguish from other occurrences of the term, which appears in various parts of physics in different forms.

Named after Boltzmann‘s H-theorem, Shannon defined the entropy Η (Greek letter Η, η) of a discrete random variable X with possible values {x1, x2, ..., xn} and probability mass function P(X) as:

H(X)=E(ln(P(x)))bubuko.com,布布扣

 

Here E is the expected value operator. When taken from a finite sample, the entropy can explicitly be written as

H(X)=bubuko.com,布布扣i=1bubuko.com,布布扣nbubuko.com,布布扣P(xbubuko.com,布布扣ibubuko.com,布布扣)logbubuko.com,布布扣 bbubuko.com,布布扣(P(xbubuko.com,布布扣ibubuko.com,布布扣))bubuko.com,布布扣

 

Where b is the base of the logarithm used. Common values of b are 2, Euler‘s number e, and 10. The unit of entropy is bit for b = 2, nat for b = e, and dit (or digit) for b = 10 respectively.

In the case of P(xi) = 0 for some i, the value of the corresponding summand 0 logb(0) is taken to be a well-known limit:

0logbubuko.com,布布扣 bbubuko.com,布布扣(0)=limbubuko.com,布布扣p0+bubuko.com,布布扣plogbubuko.com,布布扣 bbubuko.com,布布扣(p)bubuko.com,布布扣

Your task is to calculate the entropy of a finite sample with N values.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains an integer N (1 <= N <= 100) and a string S. The string S is one of "bit", "nat" or "dit", indicating the unit of entropy.

In the next line, there are N non-negative integers P1, P2, .., PN. Pi means the probability of the i-th value in percentage and the sum of Pi will be 100.

Output

For each test case, output the entropy in the corresponding unit.

Any solution with a relative or absolute error of at most 10-8 will be accepted.

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

【分析】

签到题,难点可能是在题面上,学过信息论的话看到样例就能直接打代码了。

 

The 2014 ACM-ICPC Asia Mudanjiang Regional

标签:des   style   blog   http   io   color   os   ar   for   

原文地址:http://www.cnblogs.com/jcf94/p/4061694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!