English · Original
Chinese · Translation
Formal · Original
John gave Jack a very hard problem. He wrote a very big positive integer _A_0 on a piece of paper. The number is less than 10200000 . In each step, Jack is allowed to put ' + ' signs in between some of the digits (maybe none) of the current number and calculate the sum of the expression. He can perform the same procedure on that sum and so on. The resulting sums can be labeled respectively by _A_1, _A_2 etc. His task is to get to a single digit number.
The problem is that there is not much blank space on the paper. There are only three lines of space, so he can't perform more than three steps. Since he wants to fill up the paper completely, he will perform exactly three steps.
Jack must not add leading zeros to intermediate results, but he can put ' + ' signs in front of digit 0. For example, if the current number is 1000100, 10 + 001 + 00 is a valid step, resulting in number 11.
## Input
First line contains a positive integer _N_ (1 ≤ _N_ ≤ 200000), representing the number of digits of _A_0.
Second line contains a string of length _N_ representing positive integer number _A_0. Each character is digit. There will be no leading zeros.
## Output
Output exactly three lines, the steps Jack needs to perform to solve the problem. You can output any sequence of steps which results in a single digit number (and is logically consistent).
Every step consists of digits and ' + ' signs. Steps should not contain several ' + ' signs in a row, whitespaces, or ' + ' signs as the first or last character. They also need to be arithmetically consistent.
Solution might not be unique. Output any of them in that case.
[samples]
## Note
In the first sample, Jack can't put ' + ' signs anywhere, so he just writes 1 in each line and solves the problem. Here, solution is unique.
In the second sample, Jack first puts ' + ' between every two consecutive digits, thus getting the result 5 + 8 + 0 + 6 = 19. He does the same on the second step, getting 1 + 9 = 10. Once more, he gets 1 + 0 = 1, so after three steps, the result is 1 and his solution is correct.
John 给了 Jack 一个非常困难的问题。他在一张纸上写了一个非常大的正整数 #cf_span[A0],这个数小于 #cf_span[10200000]。在每一步中,Jack 可以在当前数字的某些数字之间(可能不放)插入 #cf_span[' + '] 号,并计算表达式的和。他可以对这个和重复相同的操作,依此类推。得到的和依次记为 #cf_span[A1], #cf_span[A2] 等。他的任务是得到一个一位数。
问题是,纸上的空白空间很少,只有三行空间,因此他不能执行超过三步。由于他想完全填满纸张,他将恰好执行三步。
Jack 不能在中间结果中添加前导零,但他可以在数字 #cf_span[0] 前面放置 #cf_span[' + '] 号。例如,如果当前数字是 #cf_span[1000100],那么 #cf_span[10 + 001 + 00] 是一个合法的步骤,结果为 #cf_span[11]。
第一行包含一个正整数 #cf_span[N (1 ≤ N ≤ 200000)],表示 #cf_span[A0] 的位数。
第二行包含一个长度为 #cf_span[N] 的字符串,表示正整数 #cf_span[A0]。每个字符都是数字,且没有前导零。
请输出恰好三行,表示 Jack 为解决问题需要执行的步骤。你可以输出任何能得出一位数的步骤序列(且逻辑一致)。
每一步由数字和 #cf_span[' + '] 号组成。步骤中不能包含连续多个 #cf_span[' + '] 号、空格,或以 #cf_span[' + '] 号作为首字符或尾字符。它们还必须满足算术一致性。
解可能不唯一,在这种情况下输出任意一个即可。
在第一个样例中,Jack 无法在任何位置放置 #cf_span[' + '] 号,因此他只需在每一行写上 #cf_span[1] 即可解决问题。此时解是唯一的。
在第二个样例中,Jack 首先在每两个相邻数字之间放置 #cf_span[' + '] 号,得到结果 #cf_span[5 + 8 + 0 + 6 = 19]。第二步他同样操作,得到 #cf_span[1 + 9 = 10]。第三次操作后,得到 #cf_span[1 + 0 = 1],因此三步之后结果为 #cf_span[1],他的解是正确的。
## Input
第一行包含一个正整数 #cf_span[N (1 ≤ N ≤ 200000)],表示 #cf_span[A0] 的位数。
第二行包含一个长度为 #cf_span[N] 的字符串,表示正整数 #cf_span[A0]。每个字符都是数字,且没有前导零。
## Output
请输出恰好三行,表示 Jack 为解决问题需要执行的步骤。你可以输出任何能得出一位数的步骤序列(且逻辑一致)。
每一步由数字和 #cf_span[' + '] 号组成。步骤中不能包含连续多个 #cf_span[' + '] 号、空格,或以 #cf_span[' + '] 号作为首字符或尾字符。它们还必须满足算术一致性。
解可能不唯一,在这种情况下输出任意一个即可。
[samples]
## Note
在第一个样例中,Jack 无法在任何位置放置 #cf_span[' + '] 号,因此他只需在每一行写上 #cf_span[1] 即可解决问题。此时解是唯一的。
在第二个样例中,Jack 首先在每两个相邻数字之间放置 #cf_span[' + '] 号,得到结果 #cf_span[5 + 8 + 0 + 6 = 19]。第二步他同样操作,得到 #cf_span[1 + 9 = 10]。第三次操作后,得到 #cf_span[1 + 0 = 1],因此三步之后结果为 #cf_span[1],他的解是正确的。
**Definitions**
Let $ A_0 $ be a string of $ N $ digits representing a positive integer, $ 1 \leq N \leq 200000 $, with no leading zeros.
Let $ A_1, A_2, A_3 $ be the results of three consecutive steps, where each step involves inserting `+` signs between digits of the previous number and computing the sum (no leading zeros in intermediate results, but `+0` is allowed).
**Constraints**
1. $ A_0 $ has no leading zeros.
2. Each $ A_i $ ($i = 1,2,3$) is obtained by splitting the digit string of $ A_{i-1} $ into a sum of decimal integers (possibly single-digit), separated by `+`, with no consecutive `+`, no leading `+` or trailing `+`, and no leading zeros in any operand (except for the digit `0` alone).
3. $ A_3 $ must be a single-digit integer (i.e., $ 1 \leq A_3 \leq 9 $).
**Objective**
Output three strings $ S_1, S_2, S_3 $, where:
- $ S_1 $ is the expression for $ A_1 $ from $ A_0 $,
- $ S_2 $ is the expression for $ A_2 $ from $ A_1 $,
- $ S_3 $ is the expression for $ A_3 $ from $ A_2 $,
such that each $ S_i $ is arithmetically valid and $ A_3 \in \{1, \dots, 9\} $.
**Note**: The digital root of $ A_0 $ is $ A_0 \mod 9 $ (with 9 if divisible by 9), and it is reachable in at most three steps for any number $ < 10^{200000} $. One valid strategy is to split every digit in each step.
API Response (JSON)
{
"problem": {
"name": "A. Digits",
"description": {
"content": "John gave Jack a very hard problem. He wrote a very big positive integer _A_0 on a piece of paper. The number is less than 10200000 . In each step, Jack is allowed to put ' + ' signs in between some o",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 1000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF852A"
},
"statements": [
{
"statement_type": "Markdown",
"content": "John gave Jack a very hard problem. He wrote a very big positive integer _A_0 on a piece of paper. The number is less than 10200000 . In each step, Jack is allowed to put ' + ' signs in between some o...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "John 给了 Jack 一个非常困难的问题。他在一张纸上写了一个非常大的正整数 #cf_span[A0],这个数小于 #cf_span[10200000]。在每一步中,Jack 可以在当前数字的某些数字之间(可能不放)插入 #cf_span[' + '] 号,并计算表达式的和。他可以对这个和重复相同的操作,依此类推。得到的和依次记为 #cf_span[A1], #cf_span[A2] 等。他的...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ A_0 $ be a string of $ N $ digits representing a positive integer, $ 1 \\leq N \\leq 200000 $, with no leading zeros. \nLet $ A_1, A_2, A_3 $ be the results of three consecutive ...",
"is_translate": false,
"language": "Formal"
}
]
}