C. Ping-pong(思维)Educational Codeforces Round 99 (Rated for Div. 2)

原题链接: http://codeforces.com/contest/1455/problem/C

在这里插入图片描述
测试样例

input
3
1 1
2 1
1 7
output
0 1
1 1
0 7

PS: 这题属实有点坑,这么简单放 c c c题。一开始想复杂了,直到官方弹出来的提示:For both players, getting more wins has a higher priority than getting fewer losses. (对于这两个玩家,赢得更高的分优先于获得更低的损失)

题意: A l i c e Alice Alice B o b Bob Bob玩乒乓球游戏, A l i c e Alice Alice先发球,每次发球和接球都会损失一点耐力值。每个回合赢了的接着下一回合发球。初始 A l i c e Alice Alice x x x点, B o b Bob Bob y y y点。他们都玩得很好,问他们最终的得分。要最小化他们获得的分。

解题思路: 首先要确定的一点就是先发球的人要赢一定要多损失一个球。(所以在对方球足够的情况下谁都不想先发球,而如果对方球足够那就不可能接球,这样会交替球权,导致自己不利。这里好好理解。) 那么再考虑一个特殊的点,就是什么时候球不足够,即当发出球后自己手上没有球了。故 B o b Bob Bob总会等到 A l i c e Alice Alice发球后手上没球了之后再还手,即当 x = 1 x=1 x=1时才会接球,除此之外就不会接球。那么得分其实就是一个特判。具体看AC代码。

AC代码

/*
*blog:https://blog.csdn.net/hzf0701
*邮箱:unique_powerhouse@qq.com
*注:文章若有任何问题请私信我或评论区留言,谢谢支持。
*/
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)

using namespace std;

typedef long long ll;
const int maxn=1e5;//数组所开最大值
const int mod=1e9+7;//模
const int inf=0x3f3f3f3f;//无穷大

int t,x,y;
void solve(){
    if(x==1){
        cout<<"0 "<<y<<endl;
    }
    else{
        cout<<x-1<<" "<<y<<endl;
    }
}
int main(){
    while(cin>>t){
        while(t--){
            cin>>x>>y;
            solve();
        }
    }
    return 0;
}
posted @ 2022-03-26 16:49  unique_pursuit  阅读(16)  评论(0)    收藏  举报