杭电多校第九场 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;
}
最新文章
- github fork后的pull和保持同步
- 移动适配请使用比rem等更好的布局方案
- AngularJS控制器
- OC- @property @synthesize
- Visual Studio 2013 Update 2 and with Update 2
- java poi导入EXCEL xls文件代码
- Delphi 常用属性说明(超长)
- linux下一个C语言flock功能使用 .
- 写入cookie后只显示一次的DIV提示框代码
- 计算机程序的思维逻辑 (79) - 方便的CompletionService
- 解决跨站脚本注入,跨站伪造用户请求,sql注入等http安全漏洞
- rem ~~ 你懂了吗?
- 高质量的内容是SEO的关键
- SQLServer之修改UNIQUE约束
- 关于confluence上传文件附件预览查看时出现乱码的问题解决办法
- Vue学习4:class与style绑定
- vue实例的生命周期
- 剑指offer 3. 链表 从尾到头打印链表
- httpd基础知识
- vetur插件提示 [vue-language-server] Elements in iteration expect to have &#39;v-bind:key&#39; directives