HDU 1517 A Multiplication Game(博弈论)

题目地址:HDU 1517

NP状态转换。

可以把题目的向上乘变成向下除。这样1是终结状态,设1的时候为必败点。

根据所有能一步到达必败点的点是必胜点,所以[x,x*9]必胜点;根据只能到达必胜点的点是必败点,所以[x*9+1,x*9*2]是必败点.

然后求解。

代码如下:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;
#define LL __int64
int main()
{
    LL n, x;
    int f;
    while(scanf("%I64d",&n)!=EOF)
    {
        x=1;
        f=0;
        while(x<n)
        {
            if(!f)
                x*=9;
            else
                x*=2;
            f=1-f;
        }
        if(!f)
            puts("Ollie wins.");
        else
            puts("Stan wins.");
    }
    return 0;
}
时间: 2024-10-16 15:22:09

HDU 1517 A Multiplication Game(博弈论)的相关文章

HDU 1517 A Multiplication Game (博弈-求sg)

A Multiplication Game Problem Description Stan and Ollie play the game of multiplication by multiplying an integer p by one of the numbers 2 to 9. Stan always starts with p = 1, does his multiplication, then Ollie multiplies the number, then Stan and

HDU 1517 A Multiplication Game (博弈&amp;&amp;找规律)

A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3691    Accepted Submission(s): 2097 Problem Description Stan and Ollie play the game of multiplication by multiplying an in

HDU 1517 A Multiplication Game 博弈

A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6202    Accepted Submission(s): 3532 Problem Description Stan and Ollie play the game of multiplication by multiplying an in

hdu 1517 A Multiplication Game(必胜态,必败态)

A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5833    Accepted Submission(s): 3303 Problem Description Stan and Ollie play the game of multiplication by multiplying an in

hdu 1517 A Multiplication Game 段sg

A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3832    Accepted Submission(s): 2183 Problem Description Stan and Ollie play the game of multiplication by multiplying an in

HDU 1517: kiki&#39;s game

/** * @link http://acm.hdu.edu.cn/showproblem.php?pid=1517 * @author Sycamore * @date Aug, 21 */// Suppose that their exists a direction(vertically or horizontally) in which// the steps remaining to arrive at the destination (n-1 or m-1) is even, as

HDU 4902 Matrix multiplication

点击打开链接 Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 2113    Accepted Submission(s): 956 Problem Description Given two matrices A and B of size n×n, find the product o

HDU 4920 Matrix multiplication(矩阵相乘)

各种TEL,233啊.没想到是处理掉0的情况就可以过啊.一直以为会有极端数据.没想到竟然是这样的啊..在网上看到了一个AC的神奇的代码,经典的矩阵乘法,只不过把最内层的枚举,移到外面就过了啊...有点不理解啊,复杂度不是一样的吗.. Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 640 

hdu 4920 Matrix multiplication(矩阵乘法)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4920 Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 989    Accepted Submission(s): 396 Problem Description Given two matr