HDU 2188 mourns the victims of the 512 Wenchuan earthquake-selecting volunteers (Bashi game theory) and hdu2188
Address: HDU 2188
Bare Bashi game model.
When n = m + 1, since a maximum of m items can be taken at a time, no matter how many items are taken by the first accessor, the latter can take the remaining items at a time, and the latter wins, therefore, when the correct situation is n % (m + 1) = 0, it is facing a defeat. So when n = (m + 1) * r + s, (r is any natural number, s ≤ m), if the first accessor wants to take s items, if the latter takes x (≤ m), then the first takes m + 1-K, the result is (m + 1) (r-1, in the future, the winner will surely win. In short, we need to leave a multiple (m + 1) to the opponent to win.
The Code is as follows:
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;int main(){ int t, n, m; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); if(n%(m+1)==0) puts("Rabbit"); else puts("Grass"); } return 0;}
Mourning for the victims of the 512 Wenchuan earthquake-selecting volunteers
Assuming that the conditions remain unchanged, I decided that Lin was added to the final list.
Hangdian acm2188
Change n % (m + 1) to this