题意:两个人做游戏,每个人都可以在自己的回合里将数p乘以2到9之间的一个数,初始时p=1,谁先将p乘到大于等于n就算赢。

思路:一开始我算sg值,结果算来算去都没算明白。。。

后来看了别人题解,才豁然开朗。

首先,对于一个数m,计算出p在什么范围内可以乘到大于等于m。该范围即为[ceil(m/9), m - 1]。其中ceil()为向上取整。如果将每一个数字都看作一个局面的话,则在该区间内的点即为N点。

对于一个数m,计算出p在什么范围内只能乘到大于等于m。该范围即为[ceil(m/2), m - 1]。如果将每一个数字都看作一个局面的话,且m对应的局面为N点时,则在该区间内的点即为P点。

考虑到int类型取整的规则,将上述范围也可表示为[(m + 8) / 9, m - 1], [(m + 1) / 2, m - 1]。

 #include<stdio.h>
int main()
{
int n;
while (~scanf("%d", &n))
{
while (n)
{
n = (n + ) / ;//此时n为n点
if (n == )
{
printf("Stan wins.\n");
break;
}
n = (n + ) >> ;//此时n为p点
if (n == )
{
printf("Ollie wins.\n");
break;
}
}
}
return ;
}

POJ 2505 A multiplication game [博弈]的更多相关文章

  1. poj 2505 A multiplication game(博弈)

    A multiplication game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5622   Accepted: ...

  2. POJ 2505 A multiplication game(找规律博弈/贪心)

    题目链接 #include<iostream> #include<cstdio> using namespace std; typedef long long ll; int ...

  3. poj 2505 A multiplication game

    题目 题意:两个人轮流玩游戏,Stan先手,数字 p从1开始,Stan乘以一个2-9的数,然后Ollie再乘以一个2-9的数,直到谁先将p乘到p>=n时那个人就赢了,而且轮到某人时,某人必须乘以 ...

  4. [原博客] POJ 2505 A multiplication game 组合游戏

    题目链接题意: 有一个数p=1,甲乙两人轮流操作,每次可以把p乘2~9中的一个数,给定一个n,当一个人操作后p>=n,那么这个人赢,问先手是否必胜. 必胜状态:存在一种走法走到一个必败状态. 必 ...

  5. POJ 3673 Cow Multiplication

    Cow Multiplication Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13312   Accepted: 93 ...

  6. POJ Football Game 【NIMK博弈 && Bash 博弈】

    Football Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 451   Accepted: 178 Descr ...

  7. Poj 3318 Matrix Multiplication( 矩阵压缩)

    Matrix Multiplication Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18928   Accepted: ...

  8. 数学(矩阵乘法,随机化算法):POJ 3318 Matrix Multiplication

    Matrix Multiplication Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17783   Accepted: ...

  9. poj 3318 Matrix Multiplication

    http://poj.org/problem?id=3318 矩阵A*矩阵B是否等于矩阵C #include <cstdio> #include <cstring> #incl ...

随机推荐

  1. #3 working with data stored in files && securing your application

    This chapter reveals that you can use files and databases together to build PHP application that waa ...

  2. itchat 总结(转)

    python实现微信接口(itchat) 安装 sudo pip install itchat 登录 itchat.auto_login() 这种方法将会通过微信扫描二维码登录,但是这种登录的方式确实 ...

  3. mysql进阶二

    数据库存储数据的特点: 1.数据存放到表中,然后表再放到库中 2.一个库中可以有多张表,每张表具有唯一的表名来标识自己 3.表中有一个或多个列,列又称为“字段” 数据库常见的管理系统 mysql.or ...

  4. sql server备份

    完全备份 declare @device varchar(255),@path varchar(255),@dbname varchar(255)set @dbname='MIS_TEMP'set @ ...

  5. Robotium之Android控件定位实践和建议

    本人之前曾经撰文描述Appium和UIAutomator框架是如何定位Android界面上的控件的. UIAutomator定位Android控件的方法实践和建议Appium基于安卓的各种FindEl ...

  6. C# 中的 #region 和 #endregion 的作用

    C#中的 #region 和 #endregion 表示一块区域,这样在 Visual Studio 中可以将这块区域的代码折叠起来,便于查看. 虽然Visual Studio 也响应大括号的折叠,但 ...

  7. CSU-1985 驱R符

    CSU-1985 驱R符 Description 阴阳师中有三中稀有度的式神R,SR,SSR,其中R的稀有度最低,每次抽符,会随机得到一种式神,然而子浩君对R式神已经深恶痛绝. 某天,子浩君突然发现, ...

  8. valuestack 根对象CompoundRoot 源码

    /* * Copyright 2002-2006,2009 The Apache Software Foundation. * * Licensed under the Apache License, ...

  9. 【CCF】 Markdown 模拟

    #include<iostream> #include<cstdio> #include<string> #include<cstring> #incl ...

  10. [暑假集训--数论]poj1365 Prime Land

    Everybody in the Prime Land is using a prime base number system. In this system, each positive integ ...