• 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;
    }
  • 相关阅读:
    求24点
    关于参数和返回值的常量性
    点到平面的距离公式
    大端序与小端序
    Quake3中的绝对值函数
    整数超出范围时如何表示?
    关于数组的几道面试题
    在移位数组中查找数
    时间复杂度O(n),空间复杂度O(1)的排序
    C++之对象切割
  • 原文地址:https://www.cnblogs.com/moonbay/p/2751405.html
Copyright © 2020-2023  润新知