Test instructions
Gives a set of n numbers;
And then each time you can go to two numbers a and B, the difference between the two (big-small) is not in the collection, and put a B into the array;
Who finally can not take the number to lose;
Ask the initiator to win or to lose;
Ideas:
First, all numbers of greatest common divisor g, and the maximum of all numbers m;
For example, greatest common divisor is 2, such as the original array is 2,6,8
Then the assembly may only appear 2,4,6,8;
Likewise if the greatest common divisor of the set is 3
Then the collection can only appear 3,6,9,12 ....
So the m/g is that this set can eventually have several numbers;
Minus the original n, is also can put in a few;
To judge the parity of the knowledge that the initiator is to win the loss;
#include <cstdio> #include <cstring> #include <algorithm>using namespace std;const int n = 1005;int N, Num[n];int gcd (int x, int y) {return y = = 0? x:gcd (y, x% y);} int main () {int t;scanf ("%d", &t), while (t--) {scanf ("%d", &n), scanf ("%d", &num[0]); int g = num[0];int m = num[0 ];for (int i = 1; i < n; i++) {scanf ("%d", &num[i]), G = gcd (G,num[i]); m = max (M, Num[i]);} if (((m/g)-N)% 2) printf ("win\n"); elseprintf ("lose\n");}}
FJNU Race _acdream1684 (game)