Circle Game CodeForces - 1451D( 博弈 +思维 )

circle-game:使用websockets的实时html5游戏 圈游戏 使用websockets的实时html5游戏 立即下载

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;
}
零代码做游戏:AI辅助开发HTML5网页小游戏从创意到发布全流程 在软件开发领域,自然语言编程正成为一种新兴的人机协作方式,而AI辅助开发则是其最典型的落地形态。它让开发者无需精通语法,只需用清晰的语言描述游戏规则与交互逻辑,AI便能自动生成可运行的代码。这种模式大幅降低了编程门槛,尤其适合快速验证创意、制作原型。对于HTML5网页游戏而言,借助AI生成单个HTML文件,配合在线运行环境,即可在浏览器中直接试玩、迭代与分享。无论是产品经理验证玩法、运营人员制作互动小游戏,还是教育者设计课堂闯关,都能通过自然语言描述需求,让AI完成代码实现与报错修复。本文完整记录了一个“接 阅读详情

相关推荐

一条龙开发指南:MCP AI Agent 理论+项目实战开发你的MCP Server

MCP(Model Connection Protocol)是Anthropic于2024年推出的AI模型连接协议,旨在为AI模型提供开放、通用的标准化接口,类似于“USB-C”接口,使AI模型能够无缝连接各种数据源和工具。MCP通过标准化协议解决了AI系统集成中的碎片化问题,提升了开发效率和系统可靠性。开发者可以通过简单的配置,快速接入不同的MCP Server,实现AI模型的多样化应用。MCP支持多种协议,如Stdio、SSE等,并通过JSON-RPC格式进行数据传输。文章还以腾讯云代码助手为例,展示了

杨不易呀 3046

codeforces 博弈 Circle Game

codeforces 博弈 Circle Game

m0_62031207的博客 360

rv1126 SDK编译【2020-0912版本SDK包】

rv1126 sdk 编译

学习记录 1万+

Codeforces 1451D. Circle Game(博弈)

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 ???? coordina

tomjobs的博客 694

ANPC三电平拓扑:两种调制方式解析

ANPC结构是基于“I”型NPC结构(下面讲NPC如不特殊说明,均指的是“I”型结构NPC)发展出来的一种改进型。我们在讲NPC结构的时候会谈到他的一个缺点就是损耗分布不均匀,会导致温升不均衡,进而限制模块的功率输出能力。而ANPC结构由于多了两个开关管以及相应的两个中性点换流回路(如下图),可以更加灵活任意的配置开关管可以使损耗没有那么的不均衡,从而能一定程度上提高模块的输出功率。ANPC拓扑结构图以及增加的环流回路。

IOTBOT的博客 9487

程序化广告行业(2/89):从程序化广告深挖数据处理技巧

大家好!我一直希望能和大家在技术学习的道路上携手共进,这也是我写这一系列博客的初衷。上次我们一起学习了Python基础的数据处理知识,这次咱们借助一本程序化广告手册,深入挖掘数据处理的更多技巧。这本手册涵盖了程序化广告从概念到技术实现的诸多方面,而其中处处都涉及到数据处理,相信会给我们带来不少收获

yyy173611的博客 4572

Circle Game(博弈论)

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

m0_51864047的博客 486

本地部署大模型框架 LMStudio和Ollama+WebUI对比

之前我们的辣妈系列文章介绍了很多如何使用Ollama框架+OpenWebUI做很多大模型框架下相关的事情。之后我们也尝试了LMStudio这样一体化的工具。本文介绍下LMStudio 和 Ollama+Web UI 各有优劣,具体选择取决于你的需求。

ms44的专栏 4028

Codeforces Round #685 (Div. 2) D. Circle Game 简单博弈

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

qq_45891413的博客 480

《YOLO11改进有效涨点》 专栏目录 | 目前已有100+篇内容,内含各种Head检测头、损失函数Loss、Backbone、Neck等创新点改进【持续更新】

YOLO11改进专栏目录,YOLO11改进目录

kay_545 1万+

【AI 智能体】Windows 环境 Hermes Agent(爱马仕)安装详细过程

Windows 环境 Hermes Agent(爱马仕)安装详细过程

congge_study的博客 1830

Codeforces1451D. Circle Game(博弈论)

time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 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.

frog77 535

X线DR医学图像 --- DR医用滤线栅及摩尔纹详解 (二) 摩尔纹的产生机理

1,横向摩尔纹的表现 2,纵向摩尔纹的表现 3,摩尔纹在pitch = 143μm(注:pitch为采样间隔/周期)的FPD上的表现。 4,摩尔纹的危害(严重的影响了临床诊断) 5,摩尔纹对胸片肺部肺纹理的破坏 6,滤线栅的频率(滤线栅生产厂家的产品参数)。判断摩尔纹产生的重要依据之一 7,DR平板探测器的采样频率/空间极限分辨率 l.........

松下J27录放机 4981

codeforces1451 D. Circle Game

D. Circle Game 看到博弈题,直接打表不过并不能发现什么规律gg 后手每次按照先手对称进行移动,如果先手向右则向上,先手向上则向右,然后考虑最后一步即可。 对称技巧!!! #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #pragma GCC optimize(2) #include<set> #include<map> #include<cmath> #include<stack

Fighting_Peter的博客 407

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Codeforces 1451D. Circle Game(博弈)

Description Example input 5 2 1 5 2 10 3 25 4 15441 33 output Utkarsh Ashish Utkarsh Utkarsh Ashish Solution 典型对称博弈 先计算出若右/上交替着走能走的最远步数k 若k为奇数:先手先随便走一步,之后的每一步都与上一步后手对称,即可使得先手必胜 若k为偶数:无论先手怎么走,后手都与其对称的走,即可使得后手必胜 Code int res; ll d,k; void dfs(ll x,ll y) {

chr1stopher 503

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

【Codeforces 1451 D】Circle Game,博弈论,游戏题

problem D. Circle Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Utkarsh is forced to play yet another one of Ashish’s games. The game progresses turn by turn and as usual, Ashish moves first.

小哈里的博客 999

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Codeforces Round #685 (Div. 2) D. Circle Game(博弈)

题目链接:https://codeforc.es/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

Sankkl1的博客 480

Circle Game

思维

a12377978的博客 456

cf1451D. Circle Game(圆圈博弈、数学、博弈总结)

题目链接:https://codeforces.ml/contest/1451/problem/D 题意:A和U两个任玩游戏,最开始一个点在(0,0)。现在给定两个整数1<=d<=1e5,1<=k<=d。A先走,每次必须在横或者纵坐标上加上k。且(x,y)必须满足x*x+y*y<=d*d。如果一方不能走了则证明输了。 题解:博弈问题,很公平的博弈问题。开始以为要用到sg函数什么的,又不会emmm看来啥时候得去学一学了。差点忽略了cf以考查思维为主。 能打表的可以直接打表,

I_have_a_world的博客 2055

Codeforces Round #685 (Div. 2)——D Circle Game(思维+模拟+对称博弈)

Codeforces Round #685 (Div. 2)——D Circle Game 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

weixin_45434743的博客 338

Codeforces Round #685 (Div. 2) D. Circle Game

Codeforces Round #685 (Div. 2) D. Circle Game 题意: A和U两个人玩游戏,在一个二维平面上,初始有一点在(0,0)(0,0)(0,0)。A先手,每人每步将横坐标或者纵坐标加上kkk。并且移动后的点(x,y)(x,y)(x,y)满足x2+y2≤d2x^2+y^2\le d^2x2+y2≤d2,如果不能行动的话,就失败。问给定d,kd,kd,k,谁胜利。 思路: 我们可以假设在某一点的时候,两人都朝一个方向走,那么谁是胜者就是可以确定的。为了避免失败,后手应该朝先手

Z7784562的博客 393

D. Circle Game(思维+对称博弈)

https://codeforces.com/problemset/problem/1451/D 题意翻译 在坐标轴上,有一个以(0,0)为圆点,dd为半径的圆。 现在 Ashish 和 Utkarsh 玩游戏,Ashish 是先手。 在(0,0)处有一颗棋子,两人轮流将棋子向上或向右移动kk个单位,棋子不能移出圆,谁无法移动谁输。 思路: 两条定理 必败状态的所有后继状态都是必胜状态 必胜状态的至少一个后继状态是必败状态 假设(x,y)是必败点,那么(x+1,...

代码笔记本 723

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 mov

萧瑟的博客 310

hdu 5299 Circles Game(博弈)

题目链接:hdu 5299 Circles Game 每个分离的圆都是单独的游戏,Nim值为该圆嵌套中的圆的Nim和,最后加1. #include #include #include #include #include using namespace std; const int maxn = 20005; typedef long long ll; struc

不慌不忙、不急不躁 989

1-24综合场 补题

概率DP 1-24 打了一场综合场,状态在往下走,感觉很自闭,这张倒数了,无情补题ing; H - Sticker Album The Sticker Album of the ICPC 2020 Nlogonian Subregional just came out! Competitive programming hooligans all over the country are buying albums and collecting stickers, to celebrate the compe

qq_52383696的博客 474
上一篇: Non-Substring Subsequence CodeForces - 1451B(字符串处理问题)
下一篇: 求两行字符串的和与差 计蒜客 - A1031(字符串处理 )
Piink
博客等级 码龄7年 119粉丝 195原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值