zoukankan      html  css  js  c++  java
  • 概率 Gym 100502D Dice Game

    题目传送门

     1 /*
     2     题意:两个人各掷两个骰子,给出每个骰子的最小值和最大值,其余值连续分布
     3         问两人投掷,胜利的概率谁大
     4     数据小,用4个for 把所有的可能性都枚举一遍,统计每一次是谁胜利
     5     还有更简单的做法,就是四个数相加比大小,ZT说是平均值,竟然被他水过去了:)
     6 */
     7 #include <cstdio>
     8 #include <iostream>
     9 #include <algorithm>
    10 #include <cstring>
    11 #include <string>
    12 #include <cmath>
    13 #include <set>
    14 #include <map>
    15 #include <queue>
    16 using namespace std;
    17 
    18 const int MAXN = 1e4 + 10;
    19 const int INF = 0x3f3f3f3f;
    20 
    21 int main(void)        //Gym 100502D Dice Game
    22 {
    23     //freopen ("D.in", "r", stdin);
    24 
    25     int a[4], b[4];
    26     for (int i=0; i<4; ++i)
    27     {
    28         scanf ("%d%d", &a[i], &b[i]);
    29     }
    30 
    31     int cnt1 = 0, cnt2 = 0;
    32     for (int i=a[0]; i<=b[0]; ++i)
    33     {
    34         for (int j=a[1]; j<=b[1]; ++j)
    35         {
    36             for (int k=a[2]; k<=b[2]; ++k)
    37             {
    38                 for (int l=a[3]; l<=b[3]; ++l)
    39                 {
    40                     if (i + j > k + l)    cnt1++;
    41                     else if (i + j < k + l)    cnt2++;
    42                 }
    43             }
    44         }
    45     }
    46 
    47     if (cnt1 > cnt2)    puts("Gunnar");
    48     else if (cnt1 < cnt2)    puts ("Emma");
    49     else    puts ("Tie");
    50 
    51     return 0;
    52 }
    53 
    54 /*
    55 Emma
    56 Tie
    57 Gunnar
    58 */
    编译人生,运行世界!
  • 相关阅读:
    0401. Binary Watch (E)
    0436. Find Right Interval (M)
    0151. Reverse Words in a String (M)
    1344. Angle Between Hands of a Clock (M)
    0435. Non-overlapping Intervals (M)
    0434. Number of Segments in a String (E)
    0063. Unique Paths II (M)
    0062. Unique Paths (M)
    0100. Same Tree (E)
    0190. Reverse Bits (E)
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4448532.html
Copyright © 2011-2022 走看看