Enumeration? HDU - 4224(英语题??)

Enumeration? HDU - 4224

 In mathematics and theoretical computer science, the broadest and most abstract definition of an enumeration of a set is an exact listing of all of its elements (perhaps with repetition).
If we are blocked by a tricky but small issue, a good way is stop bothering and calculating, and just enumerates all the possible result. Here is such a case. iSea is fond of coins recently, now he gets three coins, after throwing all of them again and again, he finds some of those coins are not side equivalent, because the times it faces up and faces down are not equal. Here we assume iSea has thrown the coin enough times that we can treat this as random happened and use the number to count probability.
iSea is a typical Libra, placing in equilibrium at the first position always. He want to distribute the probability to the three coins, and each time he chooses a coin from them with this probability, throws the coin, records facing up or down, and this time after summing up all the times whether the coins face up or down the ideal probable number should be perfectly equal. Again, is this possible? Remember the probability for each coin can’t be zero.

Input
The first line contains a single integer T, indicating the number of test cases.
Each test case includes Six integers Up1, Down1, Up2, Down2, Up3, Down3, indicating the times facing up and down of the first, second and third coin, respectively.

Technical Specification
1. 1 <= T <= 10 000
2. 1 000 000 <= Up, Down <= 2 000 000

Output
For each test case, output the case number first, if possible, output “Yes”, otherwise output “No” (without quote).
Sample Input

2
1000000 1000001 1000000 1000002 1000000 1000003
1000000 1000001 1000000 1000002 2000000 1000003

Sample Output

Case 1: No
Case 2: Yes

这道题比赛的时候至少得看了不下20遍,愣是没看出题意,他妈的,看人家哗哗出题,难受啊。

题意:

isea有三个硬币,他发现其中有几个硬币是两边不相同的,这就导致抛硬币足够多的次数的时候,朝上次数和朝下次数不一样,而且题目告诉我们每次抛足够多次数并且这个次数是随机(这是重点)以此算概率(没用)
下面它又进行了抛硬币,记下了三个硬币分别朝上朝下的次数,问这些硬币有没有可能在某次最理想的情况下,三个硬币所有朝上次数等于所有朝下次数(即平均朝上朝下概率0.5)

分析:

这个题目第二段很难懂,但是重点又在第一段,1.有的硬币两面不同所以不管抛多少次上下面次数永远不同。2.每次抛次数是随机的
所以根据题目给的输入数据,这些数就他妈不能定量计算,去加减算这些数没有意义,因为每次不同,这一次也是随机的,给这些数的真正作用是因为硬币有两面不同的,导致上下面出现次数不同,让我们可以根据这个次数得到这个硬币的性质,即朝上多1,朝下多-1,等多0,这样我们得到了三种状态,只要三个性质均衡一下,换句话说就是啥都有,那么最优情况下就可以是总的朝上朝下次数相同,具体possible的情况就是000(上下面相等当然可以),1 0 -1,1 -1,1,-1 1 -1(顺序可以随意变只要有这几个就行)
举个例子001就不行,这样永远只是一面次数多

code:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int t,cas = 0;
    scanf("%d",&t);
    while(t--){
        int u1,u2,u3,d1,d2,d3;
        scanf("%d%d%d%d%d%d",&u1,&d1,&u2,&d2,&u3,&d3);
        int a = 0,b = 0,c = 0;
        if(u1 < d1) a = -1;
        else if(u1 > d1)a = 1;
        if(u2 < d2) b = -1;
        else if(u2 > d2) b = 1;
        if(u3 < d3) c = -1;
        else if(u3 > d3) c = 1;
        if(a + b + c == 0 || (abs(a+b+c) == 1 && (a == b && a != 0 || a == c && a != 0 || b == c && b != 0)))
            printf("Case %d: Yes\n",++cas);
        else
            printf("Case %d: No\n",++cas);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/codeswarrior/article/details/81105316