CF2241B.Good times Good times

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

An integer nn is said to be good if it contains at most two distinct digits in its decimal representation. For example, the integers 33, 85888588, 6767 are good, whereas the integers 123123, 94479447 are not.

You are given an integer xx (1≤x<1081 \le x \lt 10^8), which is good. Your task is to find an integer yy (2≤y≤1092 \le y \le 10^9) such that both of the following conditions are satisfied:

  • yy is good.
  • x×yx \times y is good.

若一个整数 nn 的十进制表示中至多包含两种不同的数字,则称其为“好数”。例如,整数 33、85888588、6767 是好数,而整数 123123、94479447 不是好数。

给定一个整数 xx(1≤x<1081 \le x \lt 10^8),它保证是好数。你的任务是找出一个整数 yy(2≤y≤1092 \le y \le 10^9),使得同时满足以下两个条件:

  • yy 是好数;
  • x×yx \times y 是好数。

输入格式

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

Each test case contains a single integer xx (1≤x<1081 \le x \lt 10^8). It is guaranteed that xx is good.

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

每个测试用例包含一个整数 xx(1≤x<1081 \le x \lt 10^8)。保证 xx 是“好”的。

输出格式

For each test case, print a single integer yy (2≤y≤1092 \le y \le 10^9) such that both the integers yy and x×yx \times y are good.

If there are multiple valid answers, output any one of them.

对于每个测试用例,输出一个整数 yy(2≤y≤1092 \le y \le 10^9),使得整数 yy 和 x×yx \times y 均为“好”的数。

若存在多个合法答案,输出其中任意一个即可。

输入输出样例

  • 输入#1

    4
    8
    73
    299
    6767

    输出#1

    11
    4
    26
    3366

说明/提示

For the first test case, we have x=8x = 8; choosing y=11y = 11 is valid because both y=11y = 11 and x×y=88x \times y = 88 are good.

For the second test case, we have x=73x = 73; choosing y=4y = 4 is valid because both y=4y = 4 and x×y=292x \times y = 292 are good.

对于第一个测试用例,我们有 x=8x = 8;选择 y=11y = 11 是合法的,因为 y=11y = 11 和 x×y=88x \times y = 88 均为“好”的数。

对于第二个测试用例,我们有 x=73x = 73;选择 y=4y = 4 是合法的,因为 y=4y = 4 和 x×y=292x \times y = 292 均为“好”的数。

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

首页