zoukankan      html  css  js  c++  java
  • [CF1451D] Circle Game

    Description

    坐标轴上,有一个以 ((0,0)) 为圆点,(d) 为半径的圆。现在 Ashish 和 Utkarsh 玩游戏,Ashish 是先手。在 ((0,0)) 处有一颗棋子,两人轮流将棋子向上或向右移动 (k) 个单位,棋子不能移出圆,谁无法移动谁输。

    Solution

    首先,同一根对角线上的答案相同,因为后手总可以通过与先手相反的动作来使得胜负性不变。

    因此我们只需要判断 ((n,n)) 的状态即可。

    ((n,n)) 不是必败点,当且仅当 ((n+1,n)) 在圆内。

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    
    void solve()
    {
        int n;
        int d;
    
        cin >> n >> d;
        double x = 1.0 * n / d;
        x*=x;
        for (int i = 1; i <= 1e5; i++)
        {
            if (2 * (i - 1) * (i - 1) <= x && x < i * i + (i - 1) * (i - 1))
            {
                cout << "Utkarsh" << endl;
                return;
            }
            else if (i * i + (i - 1) * (i - 1) <= x && x < 2 * i * i)
            {
                cout << "Ashish" << endl;
                return;
            }
        }
    }
    
    signed main()
    {
        ios::sync_with_stdio(false);
    
        int t;
        cin >> t;
        while (t--)
        {
            solve();
        }
    }
    
  • 相关阅读:
    WordCount的程序设计没写出来怎么办
    小程序分析
    程序单元测试
    Visual studio 2013安装
    四则运算源代码
    在VC环境下执行代码出现错误
    微点评微信软件
    软件工程学习
    查找抄袭文章
    软件附加题简答
  • 原文地址:https://www.cnblogs.com/mollnn/p/14090225.html
Copyright © 2011-2022 走看看