#15907. [GDCPC 2023] X Equals Y

    ID: 15907 传统题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P9699数学2023广东Special JudgeO2优化进制省赛/邀请赛

[GDCPC 2023] X Equals Y

[GDCPC 2023] X Equals Y

题目描述

For positive integers $X$ and $b \geq 2$, define $f(X,b)$ as a sequence which describes the base-$b$ representation of $X$, where the $i$-th element in the sequence is the $i$-th least significant digit in the base-$b$ representation of $X$. For example, $f(6, 2) = \{0, 1, 1\}$, while $f(233, 17) = \{12, 13\}$.

Given four positive integers xx, yy, AA and BB, please find two positive integers aa and bb satisfying:

  • 2≤a≤A2 \leq a \leq A
  • 2≤b≤B2 \leq b \leq B
  • f(x,a)=f(y,b)f(x, a) = f(y, b)

输入格式

There are multiple test cases. The first line of the input contains an integer $T$ ($1 \leq T \leq 10^3$) indicating the number of test cases. For each test case:

The first line contains four integers xx, yy, AA and BB (1≤x,y≤1091 \leq x,y \leq 10^9, 2≤A,B≤1092 \leq A,B \leq 10^9).

It's guaranteed that there are at most 5050 test cases satisfying max⁡(x,y)>106\max(x, y) > 10^6.

输出格式

For each test case, if valid positive integers $a$ and $b$ do not exist, output $\texttt{NO}$ in one line.

Otherwise, first output YES\texttt{YES} in one line. Then in the next line, output two integers aa and bb separated by a space. If there are multiple valid answers, you can output any of them.

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
YES
2 2
NO
YES
2 10
YES
4 5
NO
YES
779 9478

提示

(暂无提示) 标签: P9699|数学|2023|广东|Special Judge|O2优化|进制|省赛/邀请赛

来源

P9699|[GDCPC 2023] X Equals Y