zoukankan      html  css  js  c++  java
  • URAL 2068 Game of Nuts (博弈)

    题意:给定 n 堆石子,每次一个人把它们分成三堆都是奇数的,谁先不能分,谁输。

    析:因为每堆都是奇数,那么最后肯定都是要分成1的,那么就把不是1的全加和,然后判断奇偶就OK了。

    代码如下:

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    #include <cctype>
    #include <cmath>
    #include <stack>
    #define frer freopen("in.txt", "r", stdin)
    #define frew freopen("out.txt", "w", stdout)
    using namespace std;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f;
    const double PI = acos(-1.0);
    const double eps = 1e-8;
    const int maxn = 8;
    const int mod = 1e9 + 7;
    const char *mark = "+-*";
    const int dr[] = {-1, 0, 1, 0};
    const int dc[] = {0, 1, 0, -1};
    int n, m;
    const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    inline int Min(int a, int b){ return a < b ? a : b; }
    inline int Max(int a, int b){ return a > b ? a : b; }
    inline LL Min(LL a, LL b){ return a < b ? a : b; }
    inline LL Max(LL a, LL b){ return a > b ? a : b; }
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    
    int main(){
        while(scanf("%d", &n) == 1){
            int ans = 0;
            for(int i = 0; i < n; ++i){
                scanf("%d", &m);
                if(m > 2)
                    ans += m/2;
            }
            if(ans % 2 == 0)  puts("Stannis");
            else  puts("Daenerys");
        }
        return 0;
    }
    

      

  • 相关阅读:
    GO 文档笔记
    GO 切片实力踩坑
    关于接口设计的一些反思
    Jenkins 发布.net core 程序,服务端无法下载nuget包的解决方法 error NU1102: 找不到版本为 (>= 3.1.6) 的包
    RabbitMQ 基础概念进阶
    RabbitMQ 入门之基础概念
    Object.entries()使用
    shadow的属性值介绍
    行内元素的特别之处
    margin的特别之处
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5796806.html
Copyright © 2011-2022 走看看