前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HDU-1847-Good Luck in CET-4 Everybody!

HDU-1847-Good Luck in CET-4 Everybody!

作者头像
f_zyj
发布2018-01-09 11:20:12
5050
发布2018-01-09 11:20:12
举报
文章被收录于专栏:ACM小冰成长之路

ACM模版

描述

描述
描述

题解

image.png
image.png

代码

代码语言:javascript
复制
#include <iostream>
#include <cstring>

using namespace std;

const int MAXN = 1010;
const int MAXM = 32;

int n;
int f[MAXM];
int SG[MAXN];
int _hash[MAXN];

void get_SG(int n)
{
    memset(SG, 0, sizeof(SG));

    for (int i = 1; i <= n; i++)
    {
        memset(_hash, 0, sizeof(_hash));

        for (int j = 1; f[j] <= i; j++)
        {
            _hash[SG[i - f[j]]] = 1;
        }
        for (int j = 0; j <= n; j++)
        {
            if (_hash[j] == 0)
            {
                SG[i] = j;
                break;
            }
        }
    }
}

int main(int argc, const char * argv[])
{
    f[1] = 1;
    for (int i = 2; i < MAXM; i++)
    {
        f[i] = f[i - 1] << 1;
    }
    get_SG(MAXN - 1);

    while (cin >> n)
    {
        if (SG[n])
        {
            puts("Kiki");
        }
        else
        {
            puts("Cici");
        }
    }

    return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017年09月22日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 描述
  • 题解
  • 代码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档