hdu 1847 博弈找规律

来源:互联网 发布:义乌美工培训多少钱 编辑:程序博客网 时间:2024/06/11 09:54

http://acm.hdu.edu.cn/showproblem.php?pid=1847

分析:测试几组数据就看出来了。我自己测试的时候居然推错 了。嗨。(当然还是看出是巴什博弈)

网上分析:

找必败点,很容易知道当剩下3时,这是一个必败点,又每一个数减1或减2都可以成为3的倍数,意识到这点大概就会做了,

因为假如这个n不是3的倍数,那么我们总可以让它减1或减2变成3的倍数,而作为3的倍数对手是不可能一次就拿完的说,这样一直下去…………………………最终先手者一定有机会把它变成3,或是后手者自杀,故意留给先手者2的k次幂,这样就也是胜利者,所以说

3的倍数就是必败点,http://blog.csdn.net/hzxph/article/details/6660726

View Code
// I'm lanjiangzhou//C#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <math.h>#include <time.h>//C++#include <iostream>#include <algorithm>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <cctype>#include <stack>#include <string>#include <list>#include <queue>#include <map>#include <vector>#include <deque>#include <set>using namespace std;//*************************OUTPUT*************************#ifdef WIN32#define INT64 "%I64d"#define UINT64 "%I64u"#else#define INT64 "%lld"#define UINT64 "%llu"#endif//**************************CONSTANT***********************#define INF 0x3f3f3f3f// aply for the memory of the stack//#pragma comment (linker, "/STACK:1024000000,1024000000")//endint main(){    int n;    while(scanf("%d",&n)!=EOF){        if(n%3==0) printf("Cici\n");        else printf("Kiki\n");    }    return 0;}