A15727 | Sum of Two Numbers
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The sum of digits of a non-negative integer $a$ is the result of summing up its digits together when written in the decimal system. For example, the sum of digits of $123$ is $6$ and the sum of digits of $10$ is $1$ . In a formal way, the sum of digits of $\displaystyle a=\sum_{i=0}^{\infty} a_i \cdot 10^i$ , where $0 \leq a_i \leq 9$ , is defined as $\displaystyle\sum_{i=0}^{\infty}{a_i}$ .
Given an integer $n$ , find two non-negative integers $x$ and $y$ which satisfy the following conditions.
- $x+y=n$ , and
- the sum of digits of $x$ and the sum of digits of $y$ differ by at most $1$ .
It can be shown that such $x$ and $y$ always exist.
Given an integer $n$ , find two non-negative integers $x$ and $y$ which satisfy the following conditions.
- $x+y=n$ , and
- the sum of digits of $x$ and the sum of digits of $y$ differ by at most $1$ .
It can be shown that such $x$ and $y$ always exist.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 10\,000$ ).
Each test case consists of a single integer $n$ ( $1 \leq n \leq 10^9$ )
Each test case consists of a single integer $n$ ( $1 \leq n \leq 10^9$ )
输出格式
For each test case, print two integers $x$ and $y$ .
If there are multiple answers, print any.
If there are multiple answers, print any.
输入输出样例
输入 #1
5 1 161 67 1206 19
输出 #1
1 0 67 94 60 7 1138 68 14 5
In the second test case, the sum of digits of $67$ and the sum of digits of $94$ are both $13$ .
In the third test case, the sum of digits of $60$ is $6$ , and the sum of digits of $7$ is $7$ .
In the third test case, the sum of digits of $60$ is $6$ , and the sum of digits of $7$ is $7$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted