CF1674A.Number Transformation

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two integers xx and yy. You want to choose two strictly positive (greater than zero) integers aa and bb, and then apply the following operation to xx exactly aa times: replace xx with b⋅xb \cdot x.

You want to find two positive integers aa and bb such that xx becomes equal to yy after this process. If there are multiple possible pairs, you can choose any of them. If there is no such pair, report it.

For example:

  • if x=3x = 3 and y=75y = 75, you may choose a=2a = 2 and b=5b = 5, so that xx becomes equal to 3⋅5⋅5=753 \cdot 5 \cdot 5 = 75;
  • if x=100x = 100 and y=100y = 100, you may choose a=3a = 3 and b=1b = 1, so that xx becomes equal to 100⋅1⋅1⋅1=100100 \cdot 1 \cdot 1 \cdot 1 = 100;
  • if x=42x = 42 and y=13y = 13, there is no answer since you cannot decrease xx with the given operations.

给你两个整数 xx 和 yy。你需要选择两个严格为正(即大于零)的整数 aa 和 bb,然后对 xx 恰好执行 aa 次如下操作:将 xx 替换为 b⋅xb \cdot x。

你需要找到两个正整数 aa 和 bb,使得经过该过程后 xx 恰好等于 yy。如果存在多组可能的 (a,b)(a, b),你可以任选其一;如果不存在这样的数对,则报告无解。

例如:

  • 若 x=3x = 3 且 y=75y = 75,可选择 a=2a = 2 和 b=5b = 5,使得 xx 变为 3⋅5⋅5=753 \cdot 5 \cdot 5 = 75;
  • 若 x=100x = 100 且 y=100y = 100,可选择 a=3a = 3 和 b=1b = 1,使得 xx 变为 100⋅1⋅1⋅1=100100 \cdot 1 \cdot 1 \cdot 1 = 100;
  • 若 x=42x = 42 且 y=13y = 13,则无解,因为给定的操作无法使 xx 减小。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

Each test case consists of one line containing two integers xx and yy (1≤x,y≤1001 \le x, y \le 100).

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例由一行组成,包含两个整数 xx 和 yy(1≤x,y≤1001 \le x, y \le 100)。

输出格式

If it is possible to choose a pair of positive integers aa and bb so that xx becomes yy after the aforementioned process, print these two integers. The integers you print should be not less than 11 and not greater than 10910^9 (it can be shown that if the answer exists, there is a pair of integers aa and bb meeting these constraints). If there are multiple such pairs, print any of them.

If it is impossible to choose a pair of integers aa and bb so that xx becomes yy, print the integer 00 twice.

如果存在一对正整数 aa 和 bb,使得经过上述过程后 xx 变为 yy,则输出这两个整数。你输出的整数应不小于 11 且不大于 10910^9(可以证明:若答案存在,则必存在满足这些约束的一对整数 aa 和 bb)。若存在多对这样的整数,输出任意一对即可。

若不存在整数对 aa 和 bb 使得 xx 变为 yy,则输出整数 00 两次。

输入输出样例

  • 输入#1

    3
    3 75
    100 100
    42 13

    输出#1

    2 5
    3 1
    0 0

输入解题思路,AI测评打分。不知道怎么写?

首页