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. ASP.NET Web开发技术的深入总结

    [IT168技术]在国内.Net开发这个环境里, 中小型公司.或者大公司但主营业务不是软件开发里面的软件小团队.针对.Net开发者的要求都是十项全能型的全才, 能做的了从前台页面展现到最后数据存储的全 ...

  2. jmeter名词解释之时间(Elapsed Time/ Latency Time/Connection Time)

    转载时请标注源自:http://blog.csdn.net/musen518 jmeter报告结果中会出现三个时间 1. Elapsed time    经过的时间(= Sample time = L ...

  3. Elasticsearch中的CRUD

    在<玩玩儿Elasticsearch>中简介了一下elasticsearch.这篇文章.我们还是做些基础的学习.在Elasticsearch怎样进行CRUD? 如果我们正在创建的一个类似微 ...

  4. struts2 validate验证

    转自:https://blog.csdn.net/houpengfei111/article/details/9038233 自定义拦截器 要自定义拦截器需要实现com.opensymphony.xw ...

  5. [USACO09JAN] 气象测量/气象牛The Baric Bovine 解题报告(DP)

    题目链接:https://www.luogu.org/problemnew/show/P2933 Description 为了研究农场的气候,Betsy帮助农夫John做了N(1 <= N &l ...

  6. C#篇(二)——属性的实质

    属性的内部实现其实就是方法 我们平时写的代码: class Student { private int age; public int Age { get { return age; } set { ...

  7. Android RecyclerView 水平滚动+自动循环轮播

    主要处理的地方: 1.RecyclerView中Adapter的item个人可以无限轮询. 2.RecyclerView自动滑动 3.手指按下时滑动停止,手指抬起后继续自动滑动 public clas ...

  8. twig 模板引擎使渲染视图更加优雅

    在使用 laravel 的时候接触过 blade 模板引擎.在学习的时候,接触到了另外一个强大的模板引擎:twig 官网:https://twig.sensiolabs.org/ 中文手册:http: ...

  9. python中的装饰器decorator

    python中的装饰器 装饰器是为了解决以下描述的问题而产生的方法 我们在已有的函数代码的基础上,想要动态的为这个函数增加功能而又不改变原函数的代码 例如有三个函数: def f1(x): retur ...

  10. DATA_PUMP_DIR impdp 指定导出目录

    1.mkdir /tdms1/oracle/dump 2.sqlplus / as sysdba 3.create directory udir as '/tdms1/oracle/dump'; 4. ...