Some boxes are provided with limited capacity and initial capacity. Each time a stone is added to a box.
The added quantity must be less than or equal to the existing quantity in the box.
It seems like Wythoff Game. Of course it must be more complicated than that.
If the upper limit is S and the current capacity is C, if C + C * C <S & (C + 1) + (C + 1) * (C + 1)> = S, then (S, C) is obviously a defeat
Because no matter how much you get at a time, you cannot directly win, and the other party can directly win.
Then, recursively calculate the C state.
If the maximum defeat T> the current C, then find the C followed by the minimum, that is, the S-C
[Cpp]
# Include <iostream>
# Include <cstdio>
# Include <cstring>
# Include <cmath>
# Include <algorithm>
# Define N 10005
# Define LL long
# Define inf 1 <29
# Define eps 1e-7
Using namespace std;
Int get_sg (int s, int c ){
Int q = sqrt (double) s );
While (q + q * q> = s)
Q --;
If (c> q) return s-c;
Else return get_sg (q, c );
}
Int main (){
Int n, cas = 0;
While (scanf ("% d", & n )! = EOF & n ){
Int s, c;
Printf ("Case % d: \ n", ++ cas );
Int ans = 0;
While (n --){
Scanf ("% d", & s, & c );
Ans ^ = get_sg (s, c );
}
If (ans)
Puts ("Yes ");
Else
Puts ("No ");
}
Return 0;
}
Author; ACM_cxlove