#P6476. [NOI Online #2 提高组] 涂色游戏

[NOI Online #2 提高组] 涂色游戏

Background

1s 256M

Problem Description

You have 102010^{20} cells, numbered starting from 00. Initially, all cells are uncolored. Now you color them according to the following rules:

  1. Cells whose indices are multiples of p1p_1 (including cell 00, same below) are colored red.
  2. Cells whose indices are multiples of p2p_2 are colored blue.
  3. For cells whose indices are multiples of both p1p_1 and p2p_2, you may choose to color them red or blue.

Here p1p_1 and p2p_2 are given integers. If a cell index is a multiple of p1p_1 or p2p_2, then it must be colored. After ignoring all uncolored cells, you do not want there to be kk consecutive cells with the same color, because you think such a coloring scheme is boring. Given p1p_1, p2p_2, and kk, you want to know whether there exists a coloring scheme that is not boring.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT indicating the number of test cases.

Each test case consists of one line with three positive integers p1p_1, p2p_2, kk, with meanings as described above.

Output Format

For each test case, output one line with a string. If there exists a coloring scheme that is not boring, output YES, otherwise output NO.

Any output format that matches one of the formats in the samples or the statement is accepted, i.e. it is case-insensitive. For example, if the standard answer is YES, then YES/Yes/yes are all considered correct.

4
2 10 4
2 3 6
1 4 7
1 1 2
No
Yes
Yes
Yes
8
370359350 416913505 3
761592061 153246036 6
262185277 924417743 5
668232501 586472717 2
891054824 169842323 6
629603359 397927152 2
2614104 175031972 68
924509243 421614240 4
Yes
Yes
Yes
No
No
No
Yes
Yes

Hint

Test Point ID p1p_1, p2p_2 \leq kk \leq TT \leq
1 \sim 3 1515 33753375
4 \sim 6 10310^3 10310^3 10410^4
7 \sim 8 1010
9 \sim 10 10510^5 10310^3
11 \sim 12 5×1055 \times 10^5 1010
13 \sim 14 10510^5
15 10910^9 1010
16 \sim 20 10610^6

Constraints for all test points: 1T1061 \leq T \leq 10^6, 1p1,p2,k1091 \leq p_1, p_2, k \leq 10^9.

Translated by ChatGPT 5