Can someone help me with this problem?

Revision en11, by mahiro_zcy, 2025-02-25 08:07:32

One of my friends sent me this problem, and I don't know how to solve it.

I used bruteforce to solve cases with small $$$n$$$ and found that the answer is No when $$$n = 1$$$ or $$$n = 3$$$, otherwise the answer is Yes. But I don't know whether it is correct, and if it is correct, how to prove it?

Who can help me? Thank you.

The promblem statement is as follows.

Divisor Card Game

Alice and Bob are playing a card game with $$$n$$$ cards, each uniquely numbered from $$$1$$$ to $$$n$$$. Initially, all cards are placed on a table. The game proceeds in rounds as follows:

  1. Alice’s Move:
    In each round, Alice must pick one card from the table, and remove it from the table. She is allowed to pick a card numbered $$$x$$$ if and only if there exists at least one card on the table numbered $$$y$$$ that satisfies: $$$y \neq x$$$ and $$$y$$$ is a divisor of $$$x$$$.

  2. Bob’s Move:
    Immediately after Alice picks the card numbered $$$x$$$, Bob picks from the table every card whose number is a divisor of $$$x$$$ and removes them from the table. (Note: since Alice has already taken the card numbered $$$x$$$, Bob does not pick it.)

For example, if the cards are $$$[1, 2, 3, 4, 5, 6]$$$ now, and if Alice picks $$$6$$$ (she can pick $$$6$$$ because $$$1, 2, 3$$$ are divisors of $$$6$$$), then Bob will pick $$$1, 2, 3$$$ (because they are divisors of $$$6$$$). After this round, the cards become $$$[4, 5]$$$.

The rounds continue until Alice can no longer make a valid move (i.e., no card on the table satisfies the condition). At that moment, Bob picks all the cards that are still on the table and removes them from the table.

Let $$$S_A$$$ be the sum of the numbers on the cards picked by Alice, and $$$S_B $$$ be the sum of the numbers on the cards picked by Bob.

Question: Can Alice find a sequence of moves such that $$$S_A > S_B$$$?


Input

The first line contains an integer $$$T$$$ ($$$1 \leq T \leq 10^4$$$) — the number of test cases.

Each of the next $$$T$$$ lines contains an integer $$$n$$$ ($$$n \geq 1$$$) — the number of cards.

Since the time complexity of an optimal solution is unknown, the upper bound of $$$n$$$ is not specified.


Output

For each test case, output Yes if Alice can find a sequence of moves such that $$$S_A > S_B$$$; otherwise, output No.


Example

Input

5
1
2
3
4
5

Output

No
Yes
No
Yes
Yes

Explanation

Test Case 1:

When $$$n = 1$$$, the only card is $$$1$$$.

Alice cannot make a move (since there is no other card on the table), and Bob picks the only card $$$1$$$.

At the end, $$$S_A = 0$$$ and $$$S_B = 1$$$, so Alice cannot end up with $$$S_A > S_B$$$.

Test Case 2:

For $$$n = 2$$$, the cards are $$$[1, 2]$$$, and one wining sequence is:

Alice picks $$$2$$$ ($$$1 \neq 2$$$ and $$$1$$$ is a divisor of $$$2$$$). Then Bob picks card $$$1$$$ (a divisor of $$$2$$$). Then, no card is on the table.

At the end, $$$S_A = 2$$$ and $$$S_B = 1$$$, so Alice ends up with $$$S_A > S_B$$$.

Test Case 3:

For $$$n = 3$$$, the cards are $$$[1, 2, 3]$$$.

No matter which valid move Alice makes, she cannot end up with $$$S_A > S_B$$$.

Test Case 4:

For $$$n = 4$$$, the cards are $$$[1, 2, 3, 4]$$$, and one winning sequence is:

Alice picks $$$3$$$ ($$$1 \neq 3$$$ and $$$1$$$ is a divisor of $$$3$$$), then Bob picks $$$1$$$ (a divisor of $$$3$$$). Then, cards on the table become $$$[2, 4]$$$.

Then, Alice picks $$$4$$$ ($$$2 \neq 4$$$ and $$$2$$$ is a divisor of $$$4$$$), and Bob picks $$$2$$$ (a divisor of $$$4$$$). Then, no card is on the table.

At the end, $$$S_A = 3+4 = 7$$$ and $$$S_B = 1+2 = 3$$$, so Alice ends up with $$$S_A > S_B$$$.

Test Case 5:

For $$$n = 5$$$, the cards are $$$[1, 2, 3, 4, 5]$$$, and one winning sequence is:

Alice picks $$$5$$$ ($$$1 \neq 5$$$ and $$$1$$$ is a divisor of $$$5$$$), then Bob picks $$$1$$$ (a divisor of $$$5$$$). Then, cards on the table become $$$[2, 3, 4]$$$.

Then, Alice picks $$$4$$$ ($$$2 \neq 4$$$ and $$$2$$$ is a divisor of $$$4$$$), and Bob picks $$$2$$$ (a divisor of $$$4$$$). Then, cards on the table become $$$[3]$$$.

Then, Alice cannot make a move (since there is no other card on the table), and Bob picks the remaining card $$$3$$$.

At the end, $$$S_A = 5 + 4 = 9$$$ and $$$S_B = 1+2+3 = 6$$$, so Alice ends up with $$$S_A > S_B$$$.

Tags number theory

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en13 English mahiro_zcy 2025-02-25 11:02:48 2 make the format better (published)
en12 English mahiro_zcy 2025-02-25 11:02:22 101 (saved to drafts)
en11 English mahiro_zcy 2025-02-25 08:07:32 6 fixed latex equation display error
en10 English mahiro_zcy 2025-02-25 08:06:28 1 Tiny change: 'ck $1$, $2$, $3$ (bec' -> 'ck $1$, $2, $3$ (bec'
en9 English mahiro_zcy 2025-02-25 08:05:29 257
en8 English mahiro_zcy 2025-02-25 07:57:17 14
en7 English mahiro_zcy 2025-02-25 07:55:10 3 Tiny change: 'mbers are a divisor of $x$ an' -> 'mbers are divisors of $x$ an'
en6 English mahiro_zcy 2025-02-25 07:53:05 15
en5 English mahiro_zcy 2025-02-25 07:39:37 8
en4 English mahiro_zcy 2025-02-25 07:24:30 28
en3 English mahiro_zcy 2025-02-25 07:20:16 0 (published)
en2 English mahiro_zcy 2025-02-25 07:19:54 11 (saved to drafts)
en1 English mahiro_zcy 2025-02-25 07:04:50 3977 Initial revision (published)