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.
题意:
每次走k步,求走d距离远(假如走的坐标是(x,y),要时刻保证xx+yy<d*d)时谁能赢 Ashish先走
思路:
先计算出能走的最大s的值,保证ss+ss<d*d,s相当于是坐标x,然后再走,每走k步,步数++,最后判断k是否能整除2,如果能,则Ashish赢
代码:
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
long long d,k;
scanf("%lld %lld",&d,&k);
long long s=(d/k)*k;//求能整除k的数
long long s1,s2=0;
while(s*s+s*s>=d*d)
s=s-k;
s1=s;
while(s*s+s1*s1<=d*d)
{
s+=k;
s2++; //s2记录步数
}
if(s2%2==0)
printf("Ashish\n");
else
printf("Utkarsh\n");
}
return 0;
}