Rikka with Stone-Paper-Scissors

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1    Accepted Submission(s): 1

Problem Description
Did you watch the movie "Animal World"? There is an interesting game in this movie.

The rule is like traditional Stone-Paper-Scissors. At the beginning of the game, each of the two players receives several cards, and there are three types of cards: scissors, stone, paper. And then in each round, two players need to play out a card simultaneously. The chosen cards will be discarded and can not be used in the remaining part of the game.

The result of each round follows the basic rule: Scissors beat Paper, Paper beats Stone, Stone beats Scissors. And the winner will get 1 point, the loser will lose 1point, and the points will not change in the case of a draw.

Now, Rikka is playing this game with Yuta. At first, Yuta gets a Scissors cards, b Stone cards and c Paper cards; Rikka gets a′ Scissors cards, b′ Stone cards, c′Paper cards. The parameters satisfy a+b+c=a′+b′+c′. And then they will play the game exactly a+b+c rounds (i.e., they will play out all the cards).

Yuta's strategy is "random". Each round, he will choose a card among all remaining cards with equal probability and play it out.

Now Rikka has got the composition of Yuta's cards (i.e., she has got the parameters a,b,c) and Yuta's strategy (random). She wants to calculate the maximum expected final points she can get, i.e., the expected final points she can get if she plays optimally.

Hint: Rikka can make decisions using the results of previous rounds and the types of cards Yuta has played.

 
Input
The first line contains a single number t(1≤t≤104).

For each testcase, the first line contains three numbers a,b,c and the second line contains three numbers a′,b′,c′(0≤a,b,c,a′,b′,c′≤109,a+b+c=a′+b′+c′>0).

 
Output
For each testcase, if the result is an integer, print it in a line directly.

Otherwise, if the result equals to ab(|gcd(a,b)|=1,b>0, a and b are integers), output "a/b" (without the quote) in a single line.

 
Sample Input
4
2 0 0
0 2 0
1 1 1
1 1 1
1 0 0
0 0 1
123 456 789
100 200 1068
 
Sample Output
2
0
-1
3552/19
 
题意:A分别有a1,b1,c1个剪刀,石头,布,B分别有a2,b2,c2个剪刀,石头,布,B胜A获得一分,平手不得不失,A输B失去一分,求B得到最大分数的期望
分析:B要获得最大分数,则在A出剪刀的时候B一定要出石头,此时B可以得到胜A的分数但是同时会失去A可能出布失去的分数
  则A出剪刀时B得分的期望是:b2*a1/(a1+b1+c1) - b2*c1/(a1+b1+c1) 依次类推
  所以B获胜的期望是:(a1*b2-b2*c1+b1*c2-a1*c2+a2*c1-a2*b)/(a1+b1+c1)
  最后化简下分数
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e6+10;
const ll mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-8;
ll gcd( ll a, ll b ) {
if( a == 0 ) {
return b;
}
if( b == 0 ) {
return a;
}
return gcd(b%a,a);
}
int main() {
ios::sync_with_stdio(0);
ll T;
cin >> T;
while( T -- ) {
ll a1, b1, c1, a2, b2, c2;
cin >> a1 >> b1 >> c1;
cin >> a2 >> b2 >> c2;
ll t = a1*b2-b2*c1+b1*c2-a1*c2+a2*c1-a2*b1;
ll num = a1+b1+c1;
if( t%num == 0 ) {
cout << t/num << endl;
} else {
if( t < 0 ) { //注意求最大公约数时数为负数的情况
cout << t/gcd(-t,num) << "/" << num/gcd(-t,num) << endl;
} else {
cout << t/gcd(t,num) << "/" << num/gcd(t,num) << endl;
}
}
}
return 0;
}

  

杭电多校第九场 D Rikka with Stone-Paper-Scissors 数学的更多相关文章

  1. 杭电多校第九场 hdu6425 Rikka with Badminton 组合数学 思维

    Rikka with Badminton Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/O ...

  2. 杭电多校第九场 hdu6424 Rikka with Time Complexity 数学

    Rikka with Time Complexity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K ( ...

  3. 杭电多校第九场 HDU6415 Rikka with Nash Equilibrium dp

    Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K ...

  4. 2018 Multi-University Training Contest 9 杭电多校第九场 (有坑待补)

    咕咕咕了太久  多校博客直接从第三场跳到了第九场orz 见谅见谅(会补的!) 明明最后看下来是dp场 但是硬生生被我们做成了组合数专场…… 听说jls把我们用组合数做的题都用dp来了遍 这里只放了用组 ...

  5. Rikka with Game[技巧]----2019 杭电多校第九场:1005

      Rikka with Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Othe ...

  6. Rikka with Travels(2019年杭电多校第九场07题+HDU6686+树形dp)

    目录 题目链接 题意 思路 代码 题目链接 传送门 题意 定义\(L(a,b)\)为结点\(a\)到结点\(b\)的路径上的结点数,问有种\(pair(L(a,b),L(c,d))\)取值,其中结点\ ...

  7. 2019杭电多校第⑨场B Rikka with Cake (主席树,离散化)

    题意: 给定一块n*m的矩形区域,在区域内有若干点,每个顶点发出一条射线,有上下左右四个方向,问矩形被分成了几个区域? 思路: 稍加观察和枚举可以发现,区域数量=射线交点数+1(可以用欧拉定理验证,但 ...

  8. 2018 Multi-University Training Contest 1 杭电多校第一场

    抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001  Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...

  9. 2018 Multi-University Training Contest 2 杭电多校第二场

    开始逐渐习惯被多校虐orz  菜是原罪 1004  Game    (hdoj 6312) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6312 虽然披着 ...

随机推荐

  1. Linux 文件系统相关的基本概念

    本文介绍 Linux 文件系统相关的基本概念. 硬盘的物理组成 盘片硬盘其实是由单个或多个圆形的盘片组成的,按照盘片能够容纳的数据量,分为单盘(一个硬盘里面只有一个盘片)或多盘(一个硬盘里面有多个盘片 ...

  2. cogs 1317. 数列操作C 区间修改 区间查询

    1317. 数列操作C ★★★   输入文件:shuliec.in   输出文件:shuliec.out   简单对比时间限制:1 s   内存限制:128 MB [题目描述] 假设有一个长度为 n( ...

  3. 记一次织梦cms渗透测试

    记一次织梦cms渗透测试 0x01 前言 本次测试的整个流程:枚举用户名-针对性暴破-登录后台-后台编辑php文件getshell. 0x02 过程 1.登录功能模块存在用户名枚举缺陷,利用此权限先枚 ...

  4. Activiti6系列(1)- 核心数据库表及字段注释说明

    前言 本文是根据<疯狂工作流讲义-Activiti6.0>一书中提取过来的,有兴趣的可以去当当网买这本书,讲的很不错,最后还有实战案例. 虽然是提取过来的,但完全靠手打梳理,觉得有用的小伙 ...

  5. spring-boot-starter-quartz集群实践

    [**前情提要**]由于项目需要,需要一个定时任务集群,故此有了这个spring-boot-starter-quartz集群的实践.springboot的版本为:2.1.6.RELEASE:quart ...

  6. GD32电压不足时烧写程序导致程序运行异常的解决方法

    一直使用的GD32F450前段时间遇到这样一个问题,当使用J-Link供电给板子烧写程序之后,程序运行缓慢,就像运行在FLASH高速部分之外一样,但是如果使用外部供电烧写,就不会出现这个问题,而且一旦 ...

  7. 为什么我们不用JIRA

    很多人问我,缺陷管理工具,为什么不用jira?而去自己造轮子开发一款bug记录系统 缄默如我,原因众多.如果只是3-5分钟就能讲的请的时候,我会先列出什么糟点呢? 1. 收费,一个人一个月的费用差不多 ...

  8. 【0801 | Day 6】Python基础(四)

    Part 13 流程控制之while循环 一.语法 while 条件 code 1 code 2 code 3 ... ​ while True: print('*1'*100) print('*2' ...

  9. vue+el-menu实现路由刷新和导航栏菜单状态保持(局部刷新页面)

    一.菜单项激活状态保持 有时,我们在项目中会有这样一个需求,即实现 一个侧导航栏,点击不同的菜单项,右边内容会跟着变化,而页面手动刷新后想要使菜单激活状态保持,那么这个功能该如何实现呢? 现在给出以下 ...

  10. scala之构造器详解

    1.基本语法: 构造器分为主构造器和辅助构造器 class 类名(形参列表) {  // 主构造器 // 类体 def  this(形参列表) {  // 辅助构造器 } def  this(形参列表 ...