zoukankan      html  css  js  c++  java
  • HDU3910(数学期望题,题目难懂)

    Liang Guo Sha

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 590    Accepted Submission(s): 426

    Problem Description
    Maybe you know “San Guo Sha”, but I guess you didn’t hear the game: “Liang Guo Sha”!

    Let me introduce this game to you. Unlike “San Guo Sha” with its complicated rules, “Liang Guo Sha” is a simple game, it consists only four cards, two cards named “Sha”, and the other named “Shan”. 

    Alice and Bob are good friends, and they’re playing “Liang Guo Sha” now. Everyone has two cards: a “Sha” and a “Shan”. Each round, everyone choose a card of his/her own, and show it together(Just show the selected card, do not need to put it away). If both of them choose “Sha”, then Alice gets A pointsand Bob loses A points; if both of them choose “Shan”, then Alice gets B points, and Bob loses B points; otherwise, Bob gets C pointsand Alice loses C points.  

    Both Alice and Bob wants to get points as many as possible, they thought a optimal strategy: Calculating a percentage of choosing card “Sha” in order to ensure that even the opponent uses the optimal strategy, he/she can still get a highest point exceptation.
      
    Here is the question, if both Alice and Bob use the optimal strategy to make their points higher, what is the expectation point which Alice can get in a round?
     
    Input
    Several test case, process to EOF.
      Each test case has only a line, consists three positive integers: A, B, C respectively.
      1 <= A, B, C <= 100000
     
    Output
    Each test case just need to output one line, the expectation point that Alice can get. Round to 6 decimal points.
     
    Sample Input
    2 10 4
    3 3 3
     
    Sample Output
    0.200000 0.000000
    Hint
    In test case 1, both Alice and Bob calculated the best percentage of choosing “Sha”, and the their percentage are the same: 70%. If Bob do not choose the best percentage, his strategy might be targetd. For example, if Bob choose 100%, then Alice can change her percentage to 100%, Bob might lose many points. Bob is clever, so he won’t do that.
     
    Source
     
    题目意思难懂,其实想通了也很简单。
    就是一个人得分的数学期望不要受另外一个人的影响!
    设Alice取sha的概率为x,Bob取sha的概率为y。
    则Alice得分的数学期望为:
    x*y*A+(1-x)*(1-y)*B-x*(1-y)*C-y*(1-x)*C 
    = (1-x)*B-x*C+(x*A-(1-x)*B+x*C-(1-x)*C)y
     
    令y的系数为0可以解得x,
    x=(B+C)/(A+B+2*C)
     
    故数学期望为:(1-x)*B-x*C
     
    double A, B, C;
    
    int main() {
        while (~scanf("%lf %lf %lf", &A, &B, &C)) {
            double x = (B + C) / (A + B + C * 2);
            printf("%.6lf
    ", (1 - x) * B - x * C);
        }
    
        return 0;
    }
  • 相关阅读:
    现在程序员的工资是不是被高估了?
    没有基础怎么学Web前端?相关学习路线是什么?
    在大厂工作5年的大神,给前端初学者的四大建议
    我是小白0基础,现在我想学习前端开发,该如何系统的学习?
    Web前端工程师就业前景怎么样?整体薪资待遇好不好?
    没有基础怎么学Web前端?相关学习路线是什么?
    8年web前端开发经验者告诉你如何零基础学习web前端
    自学Web前端开发需具备哪些技能?(企业要求)?
    Redis cluster 有没有必要刷新 拓扑?
    maven option vs provided and dependencies vs dependencyManagement
  • 原文地址:https://www.cnblogs.com/LinKArftc/p/4912283.html
Copyright © 2011-2022 走看看