Sicily 13907. Dice Game

13907. Dice Game

Constraints

Time Limit: 1 secs, Memory Limit: 256 MB

Description

Gunnar and Emma play a lot of board games at home, so they own many dice that are not normal 6- sided dice. For example they own a die that has 10 sides with numbers 47, 48, ..., 56 on it.

There has been a big storm in Stockholm, so Gunnar and Emma have been stuck at home without electricity for a couple of hours. They have finished playing all the games they have, so they came up with a new one. Each player has 2 dice which he or she rolls.
The player with a bigger sum wins. If both sums are the same, the game ends in a tie.

Given the description of Gunnar’s and Emma’s dice, which player has higher chances of winning?

All of their dice have the following property: each die contains numbers a, a + 1, ..., b, where a and b are the lowest and highest numbers respectively on the die. Each number appears exactly on one side, so the die has b - a + 1 sides.

Input

The first line contains four integers a1, b1, a2, b2 that describe Gunnar’s dice. Die number i contains numbers ai, ai + 1, ..., bi on its sides. You may assume that 1 <=&#20; ai <=&#20; bi <=&#20; 100. You can further assume that each die has at least four sides, so ai
+ 3 <=&#20; bi. The second line contains the description of Emma’s dice in the same format.

Output

Output the name of the player that has higher probability of winning. Output “Tie” if both players have same probability of winning.

Sample Input

样例一:
1 4 1 4
1 6 1 6
样例二:
1 8 1 8
1 10 2 5
样例三:
2 5 2 7
1 5 2 5

Sample Output

样例一:
Emma
样例二:
Tie
样例三:
Gunnar

Problem Source

2015年每周一赛第四场

// Problem#: 13907
// Submission#: 3660104
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <stdio.h>

int main() {
    int a1, b1, a2, b2, a3, b3, a4, b4;
    double g = 0, e = 0;
    scanf("%d%d%d%d%d%d%d%d", &a1, &b1, &a2, &b2, &a3, &b3, &a4, &b4);
    for (int i = a1; i <= b1; i++)
        for (int j = a2; j <= b2; j++) g += i + j;
    for (int i = a3; i <= b3; i++)
        for (int j = a4; j <= b4; j++) e += i + j;
    printf(g / ((b1 - a1 + 1) * (b2 - a2 + 1)) > e / ((b4 - a4 + 1) * (b3 - a3 + 1)) ? "Gunnar\n" : (g / ((b1 - a1 + 1) * (b2 - a2 + 1)) < e / ((b4 - a4 + 1) * (b3 - a3 + 1)) ? "Emma\n" : "Tie\n"));
    return 0;
}                                 
时间: 2024-11-08 22:50:02

Sicily 13907. Dice Game的相关文章

编程题目分类(剪辑)

1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. 模拟 12. 算术与代数 13. 组合问题 14. 数论 15. 网格,几何,计算几何 [编程入门] PC 110101, uva 100, The 3n+1 problem, 难度 1 PC 110102, uva 10189, Minesweeper, 难度 1 PC 110103, uva 10137, The T

(转)sicily题目分类

Sicily题目分类 ·         [数据结构/图论] 1310 Right-Heavy Tree   笛卡尔树相关,复杂度O(N)或O(NlogN). ·1426 Phone List         电话号码前缀检索,trie树相关. ·1443 Printer Queue      基本队列操作. ·1149 等价表达式         判断表达式是否等价(递归求解) ·1136 山海经             n长序列里求m次区间询问的最大连续子区间和.线段树/RMQ ·1252

ACM学习历程—HDU 5012 Dice(ACM西安网赛)(bfs)

Problem Description There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a1.a2,a3,a4,a5,a6 to be numbers written on top face, bottom face, left face, right face, front face and back face of dice A.

HDOJ 5012 Dice

BFS爆搜 Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 284    Accepted Submission(s): 166 Problem Description There are 2 special dices on the table. On each face of the dice, a distinct nu

Sicily 1146:Lenny&#39;s Lucky Lotto(dp)

题意:给出N,M,问有多少个长度为N的整数序列,满足所有数都在[1,M]内,并且每一个数至少是前一个数的两倍.例如给出N=4, M=10, 则有4个长度为4的整数序列满足条件: [1, 2, 4, 8], [1, 2, 4, 9], [1, 2, 4, 10], [1, 2, 5, 10] 分析:可用动态规划解题,假设dp[i][j],代表满足以整数i为尾数,长度为j的序列的个数(其中每一个数至少是前一个数的两倍).那么对于整数i,dp[i][j] 等于所有dp[k][j-1]的和,其中k满足:

HDU 4652 Dice (概率DP)

Dice Problem Description You have a dice with m faces, each face contains a distinct number. We assume when we tossing the dice, each face will occur randomly and uniformly. Now you have T query to answer, each query has one of the following form: 0

sicily 1345 能量项链

先模拟一下确定理解题意,然后再找状态转移方程,注意方向~ 1 //sicily 1345 能量项链 2 #include <bits/stdc++.h> 3 4 using namespace std; 5 6 int a[205]; 7 int dp[205][205]; 8 9 int main() 10 { 11 int n; 12 while(cin >> n) 13 { 14 memset(dp, 0, sizeof(dp)); 15 for(int i=0; i<

CodeForcesGym 100502D Dice Game

Dice Game Time Limit: 1000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGym. Original ID: 100502D64-bit integer IO format: %I64d      Java class name: (Any) Gunnar and Emma play a lot of board games at home, so they own many dice

Spring-1-F Dice(HDU 5012)解题报告及测试数据

Dice Time Limit:1000MS     Memory Limit:65536KB Description There are 2 special dices on the table. On each face of the dice, a distinct number was written. Consider a 1.a 2,a 3,a 4,a 5,a 6 to be numbers written on top face, bottom face, left face, r