Sicily 13907. Dice Game

13907. Dice GameConstraints

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 41 6 1 6样例二:1 8 1 81 10 2 5样例三:2 5 2 71 5 2 5Sample Output样例一:Emma样例二:Tie样例三:GunnarProblem Source

2015年每周一赛第四场

// Problem#: 13907// Submission#: 3660104// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: // 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;}

,人生就像一杯没有加糖的咖啡,喝起来是苦涩的,

Sicily 13907. Dice Game

相关文章:

你感兴趣的文章:

标签云: