zoukankan      html  css  js  c++  java
  • hdu 1847

    博弈问题,本来以为得好好找规律,仔细一看,n才1000,直接暴力过了~

    /*
    * hdu1847/win.cpp
    * Created on: 2011-10-27
    * Author : ben
    */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    const int MAXN = 1010;
    bool ans[MAXN];
    void init() {
    memset(ans, false, sizeof(ans));
    for (int i = 1; i < MAXN; i *= 2) {
    ans[i] = true;
    }
    for (int i = 2; i < MAXN; i++) {
    int j = 1;
    while (j < i) {
    if (!ans[i - j]) {
    ans[i] = true;
    }
    j *= 2;
    }
    }
    }

    int main() {
    #ifndef ONLINE_JUDGE
    freopen("data.in", "r", stdin);
    #endif
    init();
    int n;
    while (scanf("%d", &n) == 1) {
    printf("%s\n", ans[n] ? "Kiki" : "Cici");
    }
    return 0;
    }



  • 相关阅读:
    第8章 字符串
    第7章 方法
    第6章 类和对象
    第5章 数组
    第4章 循环结构、break与continue
    第3章 选择结构
    第2章 变量、数据类型和运算符
    Codeforces Round #426 (Div. 2)
    CCNA学前基础一
    Tinkoff Challenge
  • 原文地址:https://www.cnblogs.com/moonbay/p/2226955.html
Copyright © 2011-2022 走看看