zoukankan      html  css  js  c++  java
  • 神在夏至祭降下了神谕(oracle)

    神在夏至祭降下了神谕(oracle)

    题解:
    假设输入的数为n,m,l。那么很显然有以下几个特判:

    n+m>l  -->  summer

    n+m==l && m!=0  -->  summer

    m%l==0  -->  winter

    然后我们发现k为奇数是必为winter,其实可以证明

    k为奇数时,k=a+(a+1)意味着可以直接实现winter士兵+1,summer士兵-1

    k为偶数时,显然当m也为偶数时,必为winter

    证:k=(a-1)+(a+1) 这就相当于winter士兵+2,summer士兵-2,因为m为偶数,所以成立

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    typedef long long lol;
    template <typename T> void read(T &x)
    {
        x=0;char c=getchar();
        for(;!isdigit(c);c=getchar());
        for(;isdigit(c);c=getchar())x=x*10+c-'0';
    }
    lol test,t,n,m,l;
    int main()
    {
        read(test);
        read(t);
        for(int i=1;i<=t;i++)
        {
            read(n);read(m);read(l);
            if(m%l==0){printf("Case %d: Winter
    ",i);continue;}
            if(n+m<l){printf("Case %d: Summer
    ",i);continue;}
            if(n+m==l&&m!=0){printf("Case %d: Summer
    ",i);continue;}
            if(l&1){printf("Case %d: Winter
    ",i);continue;}
            if(!(l&1)&&!(m&1)){printf("Case %d: Winter
    ",i);continue;}
            else printf("Case %d: Summer
    ",i);
        }
        return 0;
    }
  • 相关阅读:
    python-13-集合增删查
    python-14-文件操作
    python接口自动化6-参数化关联
    python接口自动化5-session关联
    python-12-字典的嵌套与int快速排序
    python-11-字典的增删改查
    python-10-列表、元组嵌套
    python-9-列表的增删改查
    python-8-字符串索引与切片
    idea设置主题颜色
  • 原文地址:https://www.cnblogs.com/huangdalaofighting/p/7412646.html
Copyright © 2011-2022 走看看