CF 1451 D. Circle Game

链接 https://codeforces.com/contest/1451/problem/D

Utkarsh is forced to play yet another one of Ashish’s games. The game progresses turn by turn and as usual, Ashish moves first.

Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the player must ensure that the token stays within a (Euclidean) distance d from (0,0).

In other words, if after a move the coordinates of the token are (p,q), then p2+q2≤d2 must hold.

The game ends when a player is unable to make a move. It can be shown that the game will end in a finite number of moves. If both players play optimally, determine who will win.

Input
The first line contains a single integer t (1≤t≤100) — the number of test cases.

The only line of each test case contains two space separated integers d (1≤d≤105) and k (1≤k≤d).

Output
For each test case, if Ashish wins the game, print “Ashish”, otherwise print “Utkarsh” (without the quotes).

Example
input
5
2 1
5 2
10 3
25 4
15441 33
output
Utkarsh
Ashish
Utkarsh
Utkarsh
Ashish
Note
In the first test case, one possible sequence of moves can be

(0,0)−→−−−Ashish (0,1)−→−−−−Utkarsh (0,2).

Ashish has no moves left, so Utkarsh wins.

在这里插入图片描述
题意
博弈论题,给你一个半径,告诉你只能在这个半径内且在第一象限,每次必须移动横坐标或纵坐标前进一个距离,问你谁能赢。

思路
分析到边界步数即可,得开long long,然后step&1就行了

代码

#include <bits/stdc++.h>
typedef long long ll;
 
const ll mod = 1e9+7;
 
using namespace std;
namespace fastIO {
    inline void input(ll& res) {
        char c = getchar();res = 0;int f = 1;
        while (!isdigit(c)) { f ^= c == '-'; c = getchar(); }
        while (isdigit(c)) { res = (res << 3) + (res << 1) + (c ^ 48);c = getchar(); }
        res = f ? res : -res;
    }
    inline ll qpow(ll a, ll b) {
        ll ans = 1, base = a;
        while (b) {
            if (b & 1) ans = (ans * base % mod +mod )%mod;
            base = (base * base % mod + mod)%mod;
            b >>= 1;
        }
        return ans;
    }
}
using namespace fastIO;
 
const int N = 1e5+5;
ll Case,n,x,y,k;
char a[N];
int sum0[N],sum1[N];

void solve(){
	int ans = 0;
	input(n);input(k);
	for(ll i=1;i<=N;i++){
		if(n*n-k*k*i*i>=0){
			ll j = sqrt(n*n-k*k*i*i);
			j/=k;
			ans = max(1ll*ans,i+j);
		} 
		else
			break;
		
	}
	//cout<<ans<<endl;
	if(ans&1) puts("Ashish");
	else puts("Utkarsh");
} 

int main(){
	Case=1;
	input(Case);
	while(Case--){
		solve(); 
	}
	return 0;
}
/*
200000
202370013
*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值