题意
Alice and Bob play ping-pong with simplified rules.
During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn’t make a return.
The one who doesn’t make a return loses this play. The winner of the play commences the next play. Alice starts the first play.
Alice has x stamina and Bob has y. To hit the ball (while serving or returning) each player spends 1 stamina, so if they don’t have any stamina, they can’t return the ball (and lose the play) or can’t serve the ball (in this case, the other player serves the ball instead). If both players run out of stamina, the game is over.
Sometimes, it’s strategically optimal not to return the ball, lose the current play, but save the stamina. On the contrary, when the server commences a play, they have to hit the ball, if they have some stamina left.
Both Alice and Bob play optimally and want to, firstly, maximize their number of wins and, secondly, minimize the number of wins of their opponent.
Calculate the resulting number of Alice’s and Bob’s wins.
题意
Alice和Bob两个人打球,Alice先发球,发球或者接球要消耗一个体力值,可以接球也可以不接球,当没有体力值接球或者没有接球即为对手得分,当两个人体力都耗完,游戏结束。最大化自己的获胜次数,最小化对手的获胜次数
题解
先手体力为x,后手为y,可以让先手一直赢x-1场,然后后手开始反击,则后手可以赢得y场,此种情况最佳,所以答案为x - 1和y
AC代码
#include<iostream>
#include<string>
using namespace std;
int main()
{
int t; cin >> t;
while (t--) {
int x, y; cin >> x >> y;
cout << x - 1 << " " << y << endl;
}
return 0;
}