Topic Portal: https://www.lydsy.com/JudgeOnline/problem.php?id=1115
Observing the problem, we can find that the number of adjacent two piles of gravel is not negative, and we are in the first heap of stones to remove the K-stone, then the number of the heap and the i-1 heap of gravel is reduced k, the number of i+1 heap and the amount of the heap is increased k. This translates to a classic game theory: Ladder Games. We remove the first heap of Stones K, then it is equivalent to the ladder on the first heap and the i-1 heap stones of the difference between the level of k stones to the I+1 heap and the first heap of the difference that level (move down one level). So there is a conclusion: ladder game results = take the odd ladder of stones to play Nim game.
Code:
#include <cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<ctime>#include<string>#include<iostream>#include<algorithm>#include<queue>#include<vector>#include<map>#definell Long Long#defineull unsigned long Long#defineMax (A, B) (A>B?A:B)#defineMin (A, b) (A<B?A:B)#defineLowbit (x) (x&-X)#defineMoD 1000000007#defineINF 0x3f3f3f3f#defineEPS 1e-18#defineMAXN 2000010inline ll read () {ll tmp=0;CharC=getchar (), f=1; for(;c<'0'||'9'<c;c=getchar ())if(c=='-') f=-1; for(;'0'<=c&&c<='9'; C=getchar ()) tmp= (tmp<<3) + (tmp<<1) +c-'0';returntmp*F;} Inline ll Power (ll A,ll b) {ll ans=1; for(; b;b>>=1){if(b&1) Ans=ans*a%mod; A=a*a%mod;}returnans;} inline ll gcd (ll A,ll b) {returnB?GCD (b,a%b): A;} InlinevoidSwapint&a,int&B) {intTmp=a; A=b; b=tmp;}using namespacestd;inta[1010];intN;intMain () {intt=read (); while(t--) {n=read (); LL TMP=0; for(intI=1; i<=n;i++) a[i]=read (); for(inti=n;i>=1; i-=2) TMP^=a[i]-a[i-1]; if(TMP) printf ("tak\n"); Elseprintf"nie\n"); }}
bzoj1115
"bzoj1115" [POI2009] Stone game kam (game theory)