HDU 6418 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): 340    Accepted Submission(s): 155


题目链接

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 1 point, 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张剪刀、b张石头、c张布

第二个人有a'张剪刀、b'张石头、c'张布

第一个人随机出,第二个人知道第一个人的牌,

这个游戏需要两个人同时出牌,赢的人分数+1,输的人分数-1,平局不加分不减分

第二个人采用最优策略出牌,问你第二个人expected final points she can get, i.e., the expected final points she can get if she plays optimally.

 

解析:

这道题感受到了智商的差距.....队友比赛的时候看了样例直接猜出来了.....

而我看了完全没有思路....

看大佬直接写出的公式ans=\frac{a'*(c-b)+b'*(a-c)+c'*(b-a)}{a+b+c}

大致的意思就是当你出一张剪刀的时候,你期望得到的分数是\frac{c}{a+b+c}-\frac{b}{a+b+c}

然后对于每一种牌算一下答案就出来了

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdlib>
typedef long long ll;
using namespace std;

const int MAXN = 2e5+10;

ll a,b,c;
ll aa,bb,cc;

ll gcd(ll x,ll y)
{
    ll tmp;
    while(y)
    {
        tmp=x%y;
        x=y;
        y=tmp;
    }
    return x;
}

int main()
{

    int t;

	cin>>t;
	while(t--)
    {
         cin>>a>>b>>c;
         cin>>aa>>bb>>cc;
         ll mu=(aa*(c-b))+bb*(a-c)+cc*(b-a);
         ll zi=a+b+c;
         ll k=gcd((mu<0?(-mu):mu),zi);
         mu=mu/k;
         zi=zi/k;
         if(zi==1) printf("%lld\n",mu);
         else printf("%lld/%lld\n",mu,zi);
    }
	return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值