神在夏至祭降下了神谕(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\n",i);continue;} if(n+m<l){printf("Case %d: Summer\n",i);continue;} if(n+m==l&&m!=0){printf("Case %d: Summer\n",i);continue;} if(l&1){printf("Case %d: Winter\n",i);continue;} if(!(l&1)&&!(m&1)){printf("Case %d: Winter\n",i);continue;} else printf("Case %d: Summer\n",i); } return 0; }