Universal Cup Judging System

Universal Cup

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

正整数 $X$ および $b\ge 2$ に対し、$f(X,b)$ を $X$ の $b$ 進法表現を表す列と定義します。この列の $i$ 番目の要素は、$X$ の $b$ 進法表現において下位から $i$ 番目の桁の数字です。例えば、$f(6,2)=\{0,1,1\}$ であり、$f(233,17)=\{12,13\}$ です。

4 つの正整数 $x$, $y$, $A$, $B$ が与えられます。次の条件を満たす 2 つの正整数 $a$ と $b$ を求めてください。

  • $2\le a\le A$
  • $2\le b\le B$
  • $f(x,a)=f(y,b)$

入力

複数のテストケースが与えられます。入力の最初の行には、テストケース数を表す整数 $T$ ($1\le T\le 10^3$) が含まれます。各テストケースについて:

最初の行には 4 つの整数 $x$, $y$, $A$, $B$ が含まれます ($1\le x,y\le 10^9$, $2\le A,B\le 10^9$)。

$\max(x,y)>10^6$ を満たすテストケースは $50$ 個以下であることが保証されます。

出力

各テストケースについて、有効な正整数 $a$ と $b$ が存在しない場合、1 行に NO を出力してください。

そうでなければ、まず 1 行に YES を出力してください。次の行に、2 つの整数 $a$ と $b$ を空白で区切って出力してください。有効な答えが複数ある場合、そのうちどれを出力してもかまいません。

入出力例

入力 1

6
1 1 1000 1000
1 2 1000 1000
3 11 1000 1000
157 291 5 6
157 291 3 6
10126 114514 789 12345

出力 1

YES
2 2
NO
YES
2 10
YES
4 5
NO
YES
779 9478

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.