C. Ping-pong

传送门
1455 C. Ping-pong
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input
The first line contains a single integer t(1≤t≤104) — the number of test cases.The first and only line of each test case contains two integers xand y (1≤x,y≤106) — Alice’s and Bob’s initial stamina.

Output
For each test case, print two integers — the resulting number of Alice’s and Bob’s wins, if both of them play optimally.

Example
Input

3
1 1
2 1
1 7

Output

0 1
1 1
0 7

思想:先判断X与Y是否为0。X为0,则输出0,y;Y为0,输出x,0;都不为0,则输出x-1,y;具体看代码实现。
AC代码

#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    ll t,x,y;
    cin>>t;
    while(t--)
    {
        cin>>x>>y;
        if(x==0&&y!=0)
        cout<<"0"<<" "<<y<<endl;
        else if(x!=0&&y==0)
            cout<<x<<" "<<"0"<<endl;
        else cout<<x-1<<" "<<y<<endl;
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

稚皓君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值