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. 轻松学习JavaScript二十二:DOM编程学习之节点操作

    DOM编程不只能够查找三种节点,也能够操作节点.那就是创建,插入,删除.替换和复制节点.先来看节点 操作方法: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQ ...

  2. linux程序设计——个人总结

    linux程序设计--个人总结 到今天为止,<linux程序设计>学习基本完毕了.从五月下旬開始接触linux,学习安装Ubuntu14.04,六月份開始学习<linux程序设计&g ...

  3. MySQl Study学习之--MySQl二进制日志管理

    MySQl Study学习之--MySQl二进制日志管理 MySQL二进制日志(Binary Log)   a.它包括的内容及作用例如以下:     包括了全部更新了数据或者已经潜在更新了数据(比方没 ...

  4. android:为TextView加入样式——下划线,颜色,设置链接样式及前背景色

    实现下划线及颜色设置: public class AtActivity extends Activity { LinearLayout ll;     /** Called when the acti ...

  5. [BZOJ1858] [SCOI2010] 序列操作 解题报告 (线段树)

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1858 Description lxhgww最近收到了一个01序列,序列里面包含了n个数, ...

  6. Sqoop框架基础

    Sqoop框架基础 本节我们主要需要了解的是大数据的一些协作框架,也是属于Hadoop生态系统或周边的内容,比如: ** 数据转换工具:Sqoop ** 文件收集库框架:Flume ** 任务调度框架 ...

  7. 使用NiftyModeEffects对话框

    最近看到一篇有关个性对话框的文章,里面介绍了非常酷的动画效果,开源的项目下载来试试,用法很简单. NoftyDialogEffects效果参考:       http://tympanus.net/D ...

  8. POJ 1144 Network【割顶】

    学习的这一篇:https://www.byvoid.com/blog/biconnect 割顶:对于无向图G,如果删除某个点u后,连通分量数目增加,称u为图的关节点或者割顶 u为割顶的条件: (1)u ...

  9. 20180929 北京大学 人工智能实践:Tensorflow笔记03

    更改的程序部分如下: 另: 难?????????????见链接: https://www.bilibili.com/video/av22530538/?p=17 + (完)

  10. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...