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
inputCopy
5
2 1
5 2
10 3
25 4
15441 33
outputCopy
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.
假设最后的位置是x坐标增加a次k,y左边增加b次k,则位置为(ak,bk)根据题意可以得到一个公式: a 2 k 2 + b 2 k 2 < = d 2 a^2k^2 + b^2k^2 <= d^2 a2k2+b2k2<=d2 根据题意可以想到我们只要得到a+b的和s的最大值来判断谁会取得胜利(因为两个人采取的都是最佳策略,所以一定会到达最大值)。上面公司可以想象成一个圆的坐标公式,很显然当x坐标于y坐标相等或者差1(因为是整数)的时候二者和最大。假设a = b,则: 2 a 2 k 2 < = d 2 2a^2k^2 <= d^2 2a2k2<=d2可以得到: a = d 2 / ( 2 k 2 ) a = \sqrt{d^2/(2k^2)} a=d2/(2k2),这时因为二者和肯定时偶数,即Utkarsh获胜,这时判断一下,如果b = a+1仍满足上面的公式,则此时和时奇数,即Ashish获胜。(为什么最多加1?因为a,b的增量是相同的,都是K,b显然不可能额外增加2次,如果可以的话,上面算出的a就不是相同时候的最大值了)
代码如下:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll d,k;
bool solve(){
ll a = sqrt((double)(d*d)/(2*k*k));
if((a*a+(a+1)*(a+1))*(k*k) <= d*d){
return true;
}else{
return false;
}
}
int main(void){
int T;
cin >> T;
while(T--){
cin >> d >> k;
if(solve()){
cout << "Ashish" << endl;
}else{
cout << "Utkarsh" << endl;
}
}
return 0;
}