Dice Game

Time Limit: 1000ms
Memory Limit: 524288KB

This problem will be judged on CodeForcesGym. Original ID: 100502D
64-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 that are not normal 6sided dice. For example they own a die that has 10 sides

with numbers 47,48,...,56 on it.

TherehasbeenabigstorminStockholm,soGunnar 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. Eachplayerhas2dicewhichheorsherolls. Theplayer with a bigger sum wins. If both sums are the same, the game ends in a tie.

Task

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 ≤ ai bi ≤ 100. You can further assume that each die has at least four sides, so ai +3 ≤ 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                                                      Sample Output 1

1 4 1 4

1 6 1 6

Emma

Sample Input 2

Sample Output 2

1 8 1 8

1 10 2 5

Tie

Sample Input 3

Sample Output 3

2 5 2 7

1 5 2 5

Gunnar

NCPC 2014 Problem D: Dice Game

解题:直接暴力搞

 #include <bits/stdc++.h>
using namespace std;
int a[],b[],A[],B[],totA,totB;
void solve(int a1,int b1,int a2,int b2,int *o,int &tot) {
for(int i = a1; i <= b1; ++i)
for(int j = a2; j <= b2; ++j)
o[tot++] = i + j;
}
int main() {
while(~scanf("%d %d %d %d",a,b,a+,b+)) {
scanf("%d %d %d %d",a+,b+,a+,b+);
totA = totB = ;
solve(a[],b[],a[],b[],A,totA);
solve(a[],b[],a[],b[],B,totB);
sort(A,A+totA);
sort(B,B+totB);
int sumA = ,sumB = ,i = ,j = ;
while(i < totA && j < totB){
if(A[i] < B[j]){
sumB += totB - j;
i++;
}else j++;
}
i = j = ;
while(i < totA && j < totB){
if(B[j] < A[i]){
sumA += totA - i;
j++;
}else i++;
}
if(sumA == sumB) puts("Tie");
else if(sumA > sumB) puts("Gunnar");
else puts("Emma");
}
return ;
}

CodeForcesGym 100502D Dice Game的更多相关文章

  1. 概率 Gym 100502D Dice Game

    题目传送门 /* 题意:两个人各掷两个骰子,给出每个骰子的最小值和最大值,其余值连续分布 问两人投掷,胜利的概率谁大 数据小,用4个for 把所有的可能性都枚举一遍,统计每一次是谁胜利 还有更简单的做 ...

  2. HDOJ 4652 Dice

      期望DP +数学推导 Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  3. 三种renderman规范引擎的dice对比

    次表面做的有些烦躁,既然如此,索性先记一下前一阵比较的PIXIE.3delight.prman的dice方式. 研究过reyes的人都知道dice,简而言之,就是为了生成高质量高精度的图片(电影CG) ...

  4. LightOJ 1248 Dice (III) 概率

    Description Given a dice with n sides, you have to find the expected number of times you have to thr ...

  5. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  6. HDU 5955 Guessing the Dice Roll

    HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...

  7. UVALive 7275 Dice Cup (水题)

    Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...

  8. HDU 4586 A - Play the Dice 找规律

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  9. CF Polycarpus' Dice (数学)

    Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

随机推荐

  1. 三角函数之美-水波纹载入LoadingView

    一.前言 学习是要总结的.近期几天学习了画图相关的,可是使用的机会较少,如今又快要遗忘了,这次看了水波纹的绘制.认为十分有意思,还是 把实现的方法记录下来.技术无他,为手熟尔.还是要多练习,空淡误国, ...

  2. 操作指定文件格式的10个Perl CPAN模块

    在Perl开发中,非常可能会碰到一些不同格式的文件--XML.PDF.CSV及RSS文件等,和一些不同的二进制数据格式.Perl应用程序须要操作这些文件,对它们进行读写. 此时.能够求助于全面Perl ...

  3. Making User-Managed Backups-17.4、Making User-Managed Backups of Online Tablespaces and Datafiles

    17.4.Making User-Managed Backups of Online Tablespaces and Datafiles 当数据库打开时,能够备份一个在线表空间全部和一个指定的数据文件 ...

  4. PermissionError: [Errno 13] in python

    出现该错误,首先尝试以管理员身份运行 cmd.exe 程序,然后关闭所有的与 python 相关的进程. 1. open 打开一个文件夹(目录),而不是文件 这一错误一般发生在使用 open函数对文件 ...

  5. 11.IntelliJ IDEA详细配置和使用教程(适用于Java开发人员)

    转自:https://blog.csdn.net/chssheng2007/article/details/79638076 前言 正所谓工欲善其事必先利其器,对开发人员而言若想提高编码效率,一款高效 ...

  6. 2.IntelliJ IDEA 2017创建JavaEE项目

    转自:https://blog.csdn.net/qq_31628285/article/details/75139909?utm_source=blogxgwz0 IntelliJ IDEA 201 ...

  7. react --- 路由传参的几种方式

    1.params 优势 : 刷新地址栏,参数依然存在缺点:只能传字符串,并且,如果传的值太多的话,url会变得长而丑陋. 2.query 优势:传参优雅,传递参数可传对象:缺点:刷新地址栏,参数丢失 ...

  8. ip反查域名的详细信息(多种方法)

    不多说,直接上干货! 至于这里怎FQ,很简单,请见我下面的博客! kali 2.0安装 lantern(成功FQ) shadowsocks(简称SSFQ软件)步骤详解 FQ软件lantern-inst ...

  9. 《剑指offer》反转链表

    一.题目描述 输入一个链表,反转链表后,输出链表的所有元素. 二.输入描述 输入一个链表 三.输出描述 返回逆转后的链表 四.牛客网提供的框架 /* struct ListNode { int val ...

  10. <Sicily>Pair

    一.题目描述 The N cities of Estiah are connected by N-1 roads. The roads are built in a way that it's alw ...