hdu 2116水题

水题,K为64的时候单独处理,其余情况就很easy了。

/*

 * hdu2116/win.cpp

 * Created on: 2012-11-2

 * 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;

typedef long long LL;

typedef unsigned long long UU;

inline bool judge(LL sum, int K) {

    LL temp = 1, low, high;

    high = temp << (K - 1);

    low = -high;

    return (sum >= low) && (sum < high);

}

inline bool judge2(LL a, LL b) {

    LL high = 0x7fffffffffffffffLL, low = -high-1;

    if(a > 0 && b > 0) {

        UU c = (UU)a + (UU)b;

        return c <= (UU)high;

    }else if(a < 0 && b < 0) {

        return a >= low - b;

    }

    return true;

}

int main() {

#ifndef ONLINE_JUDGE

    freopen("data.in", "r", stdin);

#endif

    int K;

    LL a, b;

    bool ret;

    while(scanf("%d", &K) == 1) {

        scanf("%I64d%I64d", &a, &b);

        if(K == 64) {

            ret = judge2(a, b);

        }else {

            ret = judge(a + b, K);

        }

        if(ret) {

            puts("WaHaHa");

        }else {

            puts("Yes");

        }

    }

    return 0;

}

你可能感兴趣的:(HDU)