杭电多校第九场 D Rikka with Stone-Paper-Scissors 数学
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
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.
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).
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.
2 0 0
0 2 0
1 1 1
1 1 1
1 0 0
0 0 1
123 456 789
100 200 1068
0
-1
3552/19
#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 数学的更多相关文章
- 杭电多校第九场 hdu6425 Rikka with Badminton 组合数学 思维
Rikka with Badminton Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/O ...
- 杭电多校第九场 hdu6424 Rikka with Time Complexity 数学
Rikka with Time Complexity Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K ( ...
- 杭电多校第九场 HDU6415 Rikka with Nash Equilibrium dp
Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K ...
- 2018 Multi-University Training Contest 9 杭电多校第九场 (有坑待补)
咕咕咕了太久 多校博客直接从第三场跳到了第九场orz 见谅见谅(会补的!) 明明最后看下来是dp场 但是硬生生被我们做成了组合数专场…… 听说jls把我们用组合数做的题都用dp来了遍 这里只放了用组 ...
- Rikka with Game[技巧]----2019 杭电多校第九场:1005
Rikka with Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Othe ...
- Rikka with Travels(2019年杭电多校第九场07题+HDU6686+树形dp)
目录 题目链接 题意 思路 代码 题目链接 传送门 题意 定义\(L(a,b)\)为结点\(a\)到结点\(b\)的路径上的结点数,问有种\(pair(L(a,b),L(c,d))\)取值,其中结点\ ...
- 2019杭电多校第⑨场B Rikka with Cake (主席树,离散化)
题意: 给定一块n*m的矩形区域,在区域内有若干点,每个顶点发出一条射线,有上下左右四个方向,问矩形被分成了几个区域? 思路: 稍加观察和枚举可以发现,区域数量=射线交点数+1(可以用欧拉定理验证,但 ...
- 2018 Multi-University Training Contest 1 杭电多校第一场
抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001 Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...
- 2018 Multi-University Training Contest 2 杭电多校第二场
开始逐渐习惯被多校虐orz 菜是原罪 1004 Game (hdoj 6312) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6312 虽然披着 ...
随机推荐
- java在src/test/resourse下读取properties文件
package com.jiepu; import java.io.File; import java.net.URISyntaxException; import java.util.Map; im ...
- 图片验证码+session
生成随机验证码 #!/usr/bin/env python # -*- coding:utf-8 -*- import random from PIL import Image, ImageDraw, ...
- Intent 常用方法总结
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本文主要是总结Intent 常用的方法,并封装成Utils类中 主要涉及以下内容 ...
- 禅道、jenkins部署记录
禅道部署1.检查你linux系统的位数(uname -a)2.下载对应位数的禅道包3.通过xftp工具将禅道包拷贝到虚拟机的/opt目录4.tar 对禅道包进行解压5.改配置:vi /opt/zbox ...
- 学习TensorFlow的第一天
https://www.cnblogs.com/wangxiaocvpr/p/5902086.html
- java并发编程(二)----创建并运行java线程
实现线程的两种方式 上一节我们了解了关于线程的一些基本知识,下面我们正式进入多线程的实现环节.实现线程常用的有两种方式,一种是继承Thread类,一种是实现Runnable接口.当然还有第三种方式,那 ...
- Java.基础 -------- 一个Java源文件中可以有很多类,但只能有一个类是public的
一个Java源文件中可以有很多类,但只能有一个类是public的 Java程序是从一个public类main函数开始执行的,只能有一个public是为了给类装载器提供方便,一个publi ...
- JVM运行时数据区--深入理解Java虚拟机 读后感
程序计数器 程序计数器是线程私有的区域,很好理解嘛~,每个线程当然得有个计数器记录当前执行到那个指令.占用的内存空间小,可以把它看成是当前线程所执行的字节码的行号指示器.如果线程在执行Java方法,这 ...
- 解读 PHP 的 P++提案
解读 PHP 的 P++提案 周末看到一篇文章说 PHP 创始人提议将 PHP 拉出新分支,创建 P++ 语言.随后阅读了一下 Zeev Suraski 发起的这个邮件列表,大致了解了一下,这里做个解 ...
- Web Worker 使用教程
一.概述 JavaScript 语言采用的是单线程模型,也就是说,所有任务只能在一个线程上完成,一次只能做一件事.前面的任务没做完,后面的任务只能等着.随着电脑计算能力的增强,尤其是多核 CPU 的出 ...