CodeForcesGym 100502D Dice Game
Dice Game
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的更多相关文章
- 概率 Gym 100502D Dice Game
题目传送门 /* 题意:两个人各掷两个骰子,给出每个骰子的最小值和最大值,其余值连续分布 问两人投掷,胜利的概率谁大 数据小,用4个for 把所有的可能性都枚举一遍,统计每一次是谁胜利 还有更简单的做 ...
- HDOJ 4652 Dice
期望DP +数学推导 Dice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 三种renderman规范引擎的dice对比
次表面做的有些烦躁,既然如此,索性先记一下前一阵比较的PIXIE.3delight.prman的dice方式. 研究过reyes的人都知道dice,简而言之,就是为了生成高质量高精度的图片(电影CG) ...
- LightOJ 1248 Dice (III) 概率
Description Given a dice with n sides, you have to find the expected number of times you have to thr ...
- hdu 4586 Play the Dice 概率推导题
A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- HDU 5955 Guessing the Dice Roll
HDU 5955 Guessing the Dice Roll 2016 ACM/ICPC 亚洲区沈阳站 题意 有\(N\le 10\)个人,每个猜一个长度为\(L \le 10\)的由\(1-6\) ...
- UVALive 7275 Dice Cup (水题)
Dice Cup 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/D Description In many table-top ...
- HDU 4586 A - Play the Dice 找规律
A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...
- CF Polycarpus' Dice (数学)
Polycarpus' Dice time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
随机推荐
- 2015合肥网络赛 HDU 5489 Removed Interval LIS+线段树(树状数组)
HDU 5489 Removed Interval 题意: 求序列中切掉连续的L长度后的最长上升序列 思路: 从前到后求一遍LIS,从后往前求一遍LDS,然后枚举切开的位置i,用线段树维护区间最大值, ...
- kindeditor 不能编辑 问题
/*显示上传窗体*/ function ShowUplodToDaily() { var _sdata = grid.getSelecteds(); if (_sdata) { /*创建编辑器*/ v ...
- GPU学习笔记(二)
找到了一个还不错的教程http://blog.csdn.net/augusdi/article/details/12527497 今天课比较多,但是有了这个教程解决了昨天不能运行的问题.
- 查询SqlServer最近执行过的Sql
SELECT TOP 1000ST.text AS '执行的SQL语句' ,QS.execution_count AS '执行次数' ,QS.total_elapsed_time / 10000 AS ...
- P3514 [POI2011]LIZ-Lollipop(规律+瞎搞)
题意 给一个只有1和2的序列,每次询问有没有一个子串的和为x ( 1≤n,m≤1 000 000 )kkk ( 1≤k≤2 000 000 ) 题解 我觉得是道好题. 主要是证明一个性质:假如有一个字 ...
- 浅析[分块]qwq
首先说明这篇博客写得奇差无比 让我们理清一下为什么要打分块,在大部分情况下,线段树啊,splay,treap,主席树什么的都要比分块的效率高得多,但是在出问题的时候如果你和这些数据结构只是混的脸熟的话 ...
- IDEA使用GIT 上传到GitHub
1.下载Git https://www.git-scm.com/download/ 2.安装 3.IDEA配置Git(设置Git路径,点击Test),如下代表成功 4.创建仓库 5.add 6.pus ...
- Java基础学习总结(27)——7 款开源 Java 反编译工具
今天我们要来分享一些关于Java的反编译工具,反编译听起来是一个非常高上大的技术词汇,通俗的说,反编译是一个对目标可执行程序进行逆向分析,从而得到原始代码的过程.尤其是像.NET.Java这样的运行在 ...
- BZOJ 2242 [SDOI2011]计算器 BSGS+高速幂+EXGCD
题意:id=2242">链接 方法: BSGS+高速幂+EXGCD 解析: BSGS- 题解同上.. 代码: #include <cmath> #include <c ...
- IOS 'NSInternalInconsistencyException'
今天想写一个请求的天气.好的.废话不多说.先贴代码: 使用AFNetWorking 发送get请求,可是一直报错 IOS 'NSInternalInconsistencyException', re ...