Codeforces-1451D(思维+对称博弈)

题目链接:http://codeforces.com/problemset/problem/1451/D

题目大意:两个人轮流向右或向上走,每次只能走k距离,走后的坐标(x,y)必须满足 x*x+y*y<=d*d ,否则不能走,不能走的人输。Ashish先走,两个人都按照最优策略走,让你判断谁输谁赢。

思路:对称博弈的变形。因为两个人都按照最优策略进行移动,所以如果我每次都走到(nk,nk)的点上,是走了2n步,如果还能继续走那就是A赢,如果在走一步就出去了,那即是U赢比赛 。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <utility>
#define cla(a, sum) memset(a, sum, sizeof(a))
#define rap(i, m, n) for(int i=m; i<=n; i++)
#define rep(i, m, n) for(int i=m; i>=n; i--)
#define bug printf("???\n")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int Inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int mod=998244353;
const int maxn = 1e6+5;
const int N=1e5;
template <typename T> void read(T &x){
    x = 0; int f = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

ll t,n,k;

int main()
{
	//ios::sync_with_stdio(false),cin.tie(0);
    cin>>t;
    while(t--){
        cin>>n>>k;
        ll sum=(n/k)*k;
        while(sum*sum+sum*sum>=n*n){//(x,y)x==y 的最大点
            sum-=k;
        }
        ll sum2=sum;
        ll step=-1;
        while(sum*sum+sum2*sum2<=n*n){
            step++;
            sum2+=k;
        }
        if(step%2==0){   
            cout<<"Utkarsh"<<endl;
        }
        else{
            cout<<"Ashish"<<endl;
        } 
    }
    return 0;
}


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值