CF1560F1.Nearest Beautiful Number (easy version)
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It is a simplified version of problem F2. The difference between them is the constraints (F1: k≤2, F2: k≤10).
You are given an integer n. Find the minimum integer x such that x≥n and the number x is k-beautiful.
A number is called k-beautiful if its decimal representation having no leading zeroes contains no more than k different digits. E.g. if k=2, the numbers 3434443, 55550, 777 and 21 are k-beautiful whereas the numbers 120, 445435 and 998244353 are not.
这是问题 F2 的简化版本。它们之间的区别在于约束条件(F1:k≤2,F2:k≤10)。
给定一个整数 n,请找出满足 x≥n 的最小整数 x,使得 x 是 k-beautiful 的。
若一个数的十进制表示(不含前导零)中至多包含 k 个不同的数字,则称该数为 k-beautiful。例如,当 k=2 时,数字 3434443、55550、777 和 21 是 k-beautiful 的,而数字 120、445435 和 998244353 则不是。
输入格式
The first line contains one integer t (1≤t≤104) — the number of test cases. Then t test cases follow.
Each test case consists of one line containing two integers n and k (1≤n≤109, 1≤k≤2).
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。接下来是 t 个测试用例。
每个测试用例由一行组成,包含两个整数 n 和 k(1≤n≤109,1≤k≤2)。
输出格式
For each test case output on a separate line x — the minimum k-beautiful integer such that x≥n.
对于每个测试用例,在单独的一行上输出 x —— 满足 x≥n 的最小 k-beautiful 整数。
输入输出样例
输入#1
4 1 1 221 2 177890 2 998244353 1
输出#1
1 221 181111 999999999
输入解题思路,AI测评打分。不知道怎么写?