CodeForces - 1451D

Question
Insert picture description here
Example
input
5
2 1
5 2
10 3
25 4
15441 33
output
Utkarsh
Ashish
Utkarsh
Utkarsh
Ashish

Note The
Insert picture description here


meaning of the question :
There is a circle with a radius of n, there are two people A (Ashish) and U (Utkarsh), A goes first, every You can go up or left for a distance of k at the same time.
Question: In the end, who can’t go anymore (the output is the winner). The


idea is to
figure out one thing: You can hover back and forth on the 45-degree line, similar to stairs (because of You can only go to the right or upwards, so as long as you don’t go in the direction that the previous person walked), when you go to the closest position x (x ∗ x + x ∗ x ≤ n ∗ n) The position x (x*x+x*x \leq n*n)When to go to Yi Ge most ground near the location set the X- ( the X-x+xxnn ) You can know the winning or losingcodejust by judging that there are still a few steps (0, 1, 2) out of the circle range


#include <kits/stdc++.h>
using namespnce std;
#define ll long long

int main(){
    
    
	int T; cin>>T;
	while(T--){
    
    
		ll n, k, x=0; cin>>n>>k; n*=n;
		while((x+k)*(x+k)*2<=n) x+=k; //寻找最大的x
		if(x*x*2==n || (x*x+(x+k)*(x+k))>n) cout<<"Utknrsh"<<endl; //判断几步出圆
		else cout<<"Ashish"<<endl;
	}
	
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_45757639/article/details/113098042