• 题意:对于正整数\(n\),每次可以选择使它变为\(n-1\)或者\(n/t\) (\(n\ mod\ t=0\)且\(t\)为奇数),当\(n=1\)时便不可以再取,问先手赢还是后手赢.

  • 题解:首先特判\(1\)和\(2\)的情况,然后显然如果\(n\)是奇数,一定是先手赢.

    ​ 如果\(n\)是偶数,那么我们去找它的奇数因子.

    ​ 如果没有,那么先手只能减一,后手直接赢.

    ​ 如果有,那么我们直接将它的所有奇数因子拿走,剩下一个孤零零的偶数给后手,如果这个偶数不是\(2\)的话,先手赢,否则后手赢.

  • 代码:

    1. #include <iostream>
    2. #include <cstdio>
    3. #include <cstring>
    4. #include <cmath>
    5. #include <algorithm>
    6. #include <stack>
    7. #include <queue>
    8. #include <vector>
    9. #include <map>
    10. #include <set>
    11. #include <unordered_set>
    12. #include <unordered_map>
    13. #define ll long long
    14. #define fi first
    15. #define se second
    16. #define pb push_back
    17. #define me memset
    18. const int N = 1e6 + 10;
    19. const int mod = 1e9 + 7;
    20. const int INF = 0x3f3f3f3f;
    21. using namespace std;
    22. typedef pair<int,int> PII;
    23. typedef pair<ll,ll> PLL;
    24. int t;
    25. int n;
    26. bool check(int x){
    27. for(int i=2;i<=x/i;++i){
    28. if(x%i==0){
    29. if(i!=2 && x/i!=2){
    30. if(i%2==1 || (x/i)%2==1){
    31. return true;
    32. }
    33. }
    34. }
    35. }
    36. return false;
    37. }
    38. int main() {
    39. ios::sync_with_stdio(false);cin.tie(0);
    40. cin>>t;
    41. while(t--){
    42. cin>>n;
    43. if(n==1){
    44. cout<<"FastestFinger"<<endl;
    45. }
    46. else if((n%2==1&&n>1)||n==2){
    47. cout<<"Ashishgup"<<endl;
    48. }
    49. else{
    50. if(check(n)){
    51. cout<<"Ashishgup"<<endl;
    52. }
    53. else{
    54. cout<<"FastestFinger"<<endl;
    55. }
    56. }
    57. }
    58. return 0;
    59. }

Codeforces Round #651 (Div. 2) C. Number Game (博弈,数学)的更多相关文章

  1. Codeforces Round #651 (Div. 2) C. Number Game(数论)

    题目链接:https://codeforces.com/contest/1370/problem/C 题意 给出一个正整数 $n$,Ashishgup 和 FastestFinger 依次选择执行以下 ...

  2. Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)

    Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...

  3. Codeforces Round #622 (Div. 2) B. Different Rules(数学)

    Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n ...

  4. Codeforces Round #284 (Div. 2)A B C 模拟 数学

    A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #651 (Div. 2) A Maximum GCD、B GCD Compression、C Number Game、D Odd-Even Subsequence

    A. Maximum GCD 题意: t组输入,然后输入一个n,让你在区间[1,n]之间找出来两个不相等的数a,b.求出来gcd(a,b)(也就是a,b最大公约数).让你求出来最大的gcd(a,b)是 ...

  6. Codeforces Round #266 (Div. 2) C. Number of Ways

    You've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split ...

  7. Codeforces Round #651 (Div. 2) A. Maximum GCD(数论)

    题目链接:https://codeforces.com/contest/1370/problem/A 题意 有 $n$ 个数大小分别为 $1$ 到 $n$,找出两个数间最大的 $gcd$ . 题解 若 ...

  8. Codeforces Round #651 (Div. 2) B. GCD Compression(数论)

    题目链接:https://codeforces.com/contest/1370/problem/B 题意 给出 $2n$ 个数,选出 $2n - 2$ 个数,使得它们的 $gcd > 1$ . ...

  9. Codeforces Round #651 (Div. 2) D. Odd-Even Subsequence(二分)

    题目链接:https://codeforces.com/contest/1370/problem/D 题意 给出一个含有 $n$ 个数的数组 $a$,从中选出 $k$ 个数组成子序列 $s$,使得 $ ...

随机推荐

  1. Redis Cluster 集群节点维护 (三)

    Redis Cluster 集群节点维护: 集群运行很久之后,难免由于硬件故障,网络规划,业务增长,等原因对已有集群进行相应的调整,比如增加redis nodes 节点,减少节点,节点迁移,更换服务器 ...

  2. C++ 异常机制(上)

    目录 一.概念 二.异常的好处 三.基本语法 四.栈解旋 五.异常接口声明 六.异常对象的内存模型 七.异常对象的生命周期 一.概念 异常:存在于运行时的反常行为,这些行为超过了函数的正常的功能范围. ...

  3. leetcode 117. 填充每个节点的下一个右侧节点指针 II(二叉树,DFS)

    题目链接 https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node-ii/ 题目大意 给定一个二叉树 s ...

  4. 洛谷P1972 [SDOI2009]HH的项链(树状数组)

    题目链接: https://www.luogu.org/problemnew/show/P1972 题目描述: HH 有一串由各种漂亮的贝壳组成的项链.HH 相信不同的贝壳会带来好运,所以每次散步完后 ...

  5. Oracle备份审计表SYS.AUD$和SYS.FGA_LOG$

    ORACLE的审计表不可以使用expdp和impdp导出和导入,如果使用,会报如下错误: 需要使用exp和imp进行导出和导出 导出语句: exp " '/ as sysdba' " ...

  6. JSAAS BPM快速开发平台-企业管理软件,专属你的企业管家

    前言: 2020年,企业该如何去选择合适的信息化规划管理软件,基于目前社会软件杂乱无章,选择企业业务贴近的管理软件,甚是困难,市场上一些大品牌公司的产品,定位高,价格高,扩展难,等等一系列的问题,对于 ...

  7. JavaScript中函数的定义!

    JavaScript中函数的定义! 1 自定义函数(命名函数) function fun() {}; 2 函数表达式(匿名函数) var fun = function () {}; 3 利用 new ...

  8. 提取当前文件夹下的所有文件名.bat(Windows批处理文件)

    @echo off dir /s/b *.* > 文件名.txt exit

  9. 自动化接口差异测试-diffy 回归测试 charles rewrite 请求

    https://mp.weixin.qq.com/s/vIxbtQtRRqgYCrDy7XTcrA 自动化接口差异测试-diffy Boris 搜狗测试 2018-08-30   自动化接口差异测试- ...

  10. 如何使用Conda源快速安装PyTorch?

    数据科学交流群,群号:189158789,欢迎各位对数据科学感兴趣的小伙伴的加入! 1.切换国内源 1.1.在家目录生成.condarc conda config --set show_channel ...