CF1633A.Div. 7

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given an integer nn. You have to change the minimum number of digits in it in such a way that the resulting number does not have any leading zeroes and is divisible by 77.

If there are multiple ways to do it, print any of them. If the given number is already divisible by 77, leave it unchanged.

给你一个整数 nn。你需要修改其中最少数量的数字,使得得到的新数没有前导零且能被 77 整除。

如果存在多种满足条件的修改方式,输出任意一种即可。如果给定的数本身已能被 77 整除,则无需修改。

输入格式

The first line contains one integer tt (1≤t≤9901 \le t \le 990) — the number of test cases.

Then the test cases follow, each test case consists of one line containing one integer nn (10≤n≤99910 \le n \le 999).

第一行包含一个整数 tt(1≤t≤9901 \le t \le 990)—— 表示测试用例的数量。

接下来是各测试用例,每个测试用例占一行,包含一个整数 nn(10≤n≤99910 \le n \le 999)。

输出格式

For each test case, print one integer without any leading zeroes — the result of your changes (i. e. the integer that is divisible by 77 and can be obtained by changing the minimum possible number of digits in nn).

If there are multiple ways to apply changes, print any resulting number. If the given number is already divisible by 77, just print it.

对于每个测试用例,输出一个不含前导零的整数——即经过修改后得到的结果(即能被 77 整除、且通过修改 nn 中最少位数的数字所得到的整数)。

若存在多种修改方案,输出任意一种所得的数字即可。若给定的数字本身已能被 77 整除,则直接输出该数字。

输入输出样例

  • 输入#1

    3
    42
    23
    377

    输出#1

    42
    28
    777

说明/提示

In the first test case of the example, 4242 is already divisible by 77, so there's no need to change it.

In the second test case of the example, there are multiple answers — 2828, 2121 or 6363.

In the third test case of the example, other possible answers are 357357, 371371 and 378378. Note that you cannot print 077077 or 7777.

在示例的第一个测试用例中,4242 已经能被 77 整除,因此无需修改。

在示例的第二个测试用例中,存在多个正确答案——2828、2121 或 6363。

在示例的第三个测试用例中,其他可能的答案还有 357357、371371 和 378378。注意,你不能输出 077077 或 7777。

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

首页