A14784 | Div. 7
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given an integer $n$ . 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 $7$ .
If there are multiple ways to do it, print any of them. If the given number is already divisible by $7$ , leave it unchanged.
If there are multiple ways to do it, print any of them. If the given number is already divisible by $7$ , leave it unchanged.
输入格式
The first line contains one integer $t$ ( $1 \le t \le 990$ ) — the number of test cases.
Then the test cases follow, each test case consists of one line containing one integer $n$ ( $10 \le n \le 999$ ).
Then the test cases follow, each test case consists of one line containing one integer $n$ ( $10 \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 $7$ and can be obtained by changing the minimum possible number of digits in $n$ ).
If there are multiple ways to apply changes, print any resulting number. If the given number is already divisible by $7$ , just print it.
If there are multiple ways to apply changes, print any resulting number. If the given number is already divisible by $7$ , just print it.
输入输出样例
输入 #1
3 42 23 377
输出 #1
42 28 777
In the first test case of the example, $42$ is already divisible by $7$ , so there's no need to change it.
In the second test case of the example, there are multiple answers — $28$ , $21$ or $63$ .
In the third test case of the example, other possible answers are $357$ , $371$ and $378$ . Note that you cannot print $077$ or $77$ .
In the second test case of the example, there are multiple answers — $28$ , $21$ or $63$ .
In the third test case of the example, other possible answers are $357$ , $371$ and $378$ . Note that you cannot print $077$ or $77$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted