HDU 1847 - Good Luck in CET-4 Everybody!

巴什博奕。

代码如下:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
bool ways[1002];
int vis[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int main()
{
#ifdef test
    freopen("input.txt", "r", stdin);
#endif
    int n;
    ways[0] = false;
    while(scanf("%d", &n) != EOF)
    {
        for(int i=1; i<=n; ++i)
            {
                ways[i] = false;
                for(int j=0; j<10; ++j)
                    if(i>=vis[j] && !ways[i-vis[j]])
                    {
                        ways[i] = true;
                        break;
                    }
            }
        if(ways[n])
            printf("Kiki\n");
        else
            printf("Cici\n");
    }
    return 0;
}


猜你喜欢

转载自blog.csdn.net/GooMaple/article/details/8883259