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 ;
}

最新文章

  1. MySQL多表查询
  2. Python黑帽编程2.9 面向对象编程
  3. RabbitMQ消息机制单人分发
  4. HTTP权威协议笔记-6.代理
  5. question
  6. 木耳听歌记---Clip+安装Rockbox
  7. [Google Guava]学习--新集合类型Multiset
  8. python字符类型的一些方法
  9. 同一个项目,项目名称不一致,这两个项目同时在Eclipse中出现
  10. GDC2014免费slide整理下载
  11. Android TextView多行文本滚动实现
  12. Probabilistic SVM 与 Kernel Logistic Regression(KLR)
  13. get top k elements of the same key in hive
  14. List&lt;int&gt;是值类型还是引用类型
  15. poj 1204
  16. MySQL联合索引VS单列索引
  17. java.lang.RuntimeException: Cannot create a secure XMLInputFactory 异常处理
  18. 官网下载MySQL最新版本的安装包
  19. C/C++.全文件名全路径名分割拆分分解
  20. eclipse选中某个字段没法高亮其他相同字段

热门文章

  1. 转:app store 注册账号生成证书上传app完整的教程
  2. 10.29 工作笔记 ndk编译C++,提示找不到头文件(ndk-build error: string: No such file or directory)
  3. 5.IntellijIDEA常用快捷键总结
  4. 继承—Monkey
  5. PGA和UGA内存的使用情况
  6. ng-show ng-hide ng-if的区别
  7. MongoDB 的replicattion 复制集练习
  8. type与isinstance使用区别
  9. MySql系列之表的数据类型
  10. HDU 4398 Template Library Management (最优页面调度算法)