hdu1517A Multiplication Game

链接:http://acm.hdu.edu.cn/showproblem.php?pid=1517

题意:给定一个整数n,先手从1开始操作,谁先使这个数字>=n谁就获胜。操作:乘以2~9任意一个数。

分析:之前做的博弈都是将大数减小,这种博弈是变大,有点不同,但是博弈的基础理论还是不变的,设P(必败点),N(必胜点),那么初始有n~∞是必败点,那么能一步操作到达必败点为必胜点:n/9~n-1(/为向上取整),一步操作只能到达必胜点为必败点:n/9/2~n/9-1。最后只需要看1是必败还是必胜。PS:网上好多题解说要用浮点才能过。。那是因为他们直接用整除而忽略了余数的意义,所以只能用浮点过。

代码:

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<math.h>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N=1000010;
const int MAX=1000000100;
const int mod=100000000;
const int MOD1=1000000007;
const int MOD2=1000000009;
const double EPS=0.00000001;
typedef long long ll;
const ll MOD=998244353;
const int INF=1000000010;
typedef double db;
typedef unsigned long long ull;
int main()
{
    ll n;
    while (scanf("%I64d", &n)!=EOF) {
        while (n>18) n=n/18+n%18;
        if (n<=9) printf("Stan wins.\n");
        else printf("Ollie wins.\n");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值