题目描述
Problem Background
You cannot rest now; deadlines are lurking around.
Lotus is working on her programming assignment. Besides writing the program code, typesetting the submission to make a good impression on the teaching assistants is equally important.
As is well known, code and certain special texts in articles need line numbers, but they are often very long, and adding them manually can easily lead to errors. Therefore, Lotus decides to create her own tool and write a line number generator.
Problem Description
Lotus wants to implement a function: input a text file and add line numbers to it.
Here are the definitions of three basic concepts in this problem:
- Text characters consist of all visible characters in the ASCII set, as well as the space character (ASCII=32).
- A line of characters consists of any number (including zero) of text characters, followed by exactly one newline character (ASCII=10) at the end.
- A text file consists of any number (at least one) of lines. The number of lines in the text file is the number of lines it is composed of.
Here is the method for adding line numbers in this problem:
- Suppose the text file has a total of $m$ lines. Let the width of the integer $m$ be $s$. Then, at the beginning of each line, there will be a space of $s+1$ characters to display the line number.
- For the $i$-th line, if the width of $i$ is $t$, then the line number will be displayed as $\underbrace{\texttt{␣␣...␣}}_{s-t\text{ 个}}\ i\ \texttt{␣}$, where $\texttt{␣}$ represents a space.
Here is an example:
$$\boxed{\begin{aligned} &\verb!#include<iostream>!\\ &\verb!using namespace std;!\\ &\verb!int main(){!\\ &\verb! int a, b;!\\ &\verb! cin >> a >> b;!\\ &\verb! cout << a + b << endl;!\\ &\verb! cout << a - b << endl;!\\ &\verb! cout << a * b << endl;!\\ &\verb! cout << a / b << endl;!\\ &\verb! return 0;!\\ &\verb!}! \end{aligned}} \Rightarrow \boxed{\begin{aligned} &\verb! 1 #include<iostream>!\\ &\verb! 2 using namespace std;!\\ &\verb! 3 int main(){!\\ &\verb! 4 int a, b;!\\ &\verb! 5 cin >> a >> b;!\\ &\verb! 6 cout << a + b << endl;!\\ &\verb! 7 cout << a - b << endl;!\\ &\verb! 8 cout << a * b << endl;!\\ &\verb! 9 cout << a / b << endl;!\\ &\verb!10 return 0;!\\ &\verb!11 }! \end{aligned}} $$
For easier observation, all spaces are replaced with the $\verb!␣!$ character representing a space.
Input Format
The input contains several lines, representing the original text file.
Output Format
The output contains several lines, representing the text file with added line numbers.
Sample Input and Output
Input Sample #1
#include<iostream>
using namespace std;
int main(){
int a, b;
cin >> a >> b;
cout << a + b << endl;
cout << a - b << endl;
cout << a * b << endl;
cout << a / b << endl;
return 0;
}
Output Sample #1
1 #include<iostream>
2 using namespace std;
3 int main(){
4 int a, b;
5 cin >> a >> b;
6 cout << a + b << endl;
7 cout << a - b << endl;
8 cout << a * b << endl;
9 cout << a / b << endl;
10 return 0;
11 }
Input Sample #2
public class Main {
public static void main(String[] args) throws Exception {
int b = 0, c = 0;
for (int a = 123; a < 333; a++) {
int[] array = new int[10];
Boolean flag = true;
b = a * 2;
c = a * 3;
array[a / 100] = 1;
array[a / 10 % 10] = 1;
array[a % 10] = 1;
array[b / 100] = 1;
array[b / 10 % 10] = 1;
array[b % 10] = 1;
array[c / 100] = 1;
array[c / 10 % 10] = 1;
array[c % 10] = 1;
for (int i = 1; i < array.length; i++) {
if (array[i] != 1) {
flag = false;
break;
}
}
if (flag)
System.out.println(a + " " + b + " " + c);
}
}
}
Output Sample #2
1 public class Main {
2 public static void main(String[] args) throws Exception {
3 int b = 0, c = 0;
4 for (int a = 123; a < 333; a++) {
5 int[] array = new int[10];
6 Boolean flag = true;
7 b = a * 2;
8 c = a * 3;
9 array[a / 100] = 1;
10 array[a / 10 % 10] = 1;
11 array[a % 10] = 1;
12
13 array[b / 100] = 1;
14 array[b / 10 % 10] = 1;
15 array[b % 10] = 1;
16
17 array[c / 100] = 1;
18 array[c / 10 % 10] = 1;
19 array[c % 10] = 1;
20 for (int i = 1; i < array.length; i++) {
21 if (array[i] != 1) {
22 flag = false;
23 break;
24 }
25 }
26 if (flag)
27 System.out.println(a + " " + b + " " + c);
28 }
29 }
30 }
Input Sample #3
Tao hua kai yo li hua kai, jie jie mei mei dong qi lai;
Tao hua kai yo li hua kai, jie jie mei mei tiao qi lai.
Gei ni zi ji, chun yi mai huai (yi ya yo);
Gei xin shang ren, chun se man kai.
Tao hua kai yo li hua kai, jie jie mei mei dong qi lai;
Tao hua kai yo li hua kai, jie jie mei mei tiao qi lai.
Gei tong bao men, chun yi man huai, hai hai yo;
Gei zhe da di, chun se quan kai!!!
Cong na nu jiang nan, dao mo he bei,
Dao chu dou you hua rong ming mei.
Lai hui hui shou, zai diao ge tou,
Wu xian chun guang zai wo xiong.
Cong jing cheng, dao yuan ye,
Dao chu dou you sheng de xi yue.
Lai hui hui shou, zai yan ran huang ge tou,
Wu xian CHUN GUANG XIAN ZU GUO!!!
Tao hua kai yo li hua kai, Jiong xian mei mei dong qi lai;
Tao hua kai yo li hua kai, Jie jie mei mei tiao qi lai.
Gei ni zi ji, chun yi mai huai chun yi man huai yi ya yo;
Gei xin shang ren, chun se man kai chun se man kai.
Tao hua kai yo li hua kai, Jie jie mei mei dong qi lai;
Tao hua kai yo li hua kai, Jie jie mei mei tiao qi lai.
Gei tong bao men, chun yi man huai, hai hai yo;
Gei zhe da di, chun se quan kai!!!
Cong na nu jiang nan, dao mo he bei,
Dao chu dou you hua rong ming mei.
Lai hui hui shou, zai diao ge tou,
Wu xian chun guang zai wo xiong.
Cong jing cheng, dao yuan ye,
Dao chu dou you sheng de xi yue.
Lai hui hui shou, zai yan ran huang ge tou,
Wu xian CHUN GUANG XIAN ZU GUO!!!
Lai hui hui shou, zai yan ran huang ge tou,
Wu xian CHUN GUANG XIAN ZU GUO!!!
Output Sample #3
1 Tao hua kai yo li hua kai, jie jie mei mei dong qi lai;
2 Tao hua kai yo li hua kai, jie jie mei mei tiao qi lai.
3 Gei ni zi ji, chun yi mai huai (yi ya yo);
4 Gei xin shang ren, chun se man kai.
5 Tao hua kai yo li hua kai, jie jie mei mei dong qi lai;
6 Tao hua kai yo li hua kai, jie jie mei mei tiao qi lai.
7 Gei tong bao men, chun yi man huai, hai hai yo;
8 Gei zhe da di, chun se quan kai!!!
9 Cong na nu jiang nan, dao mo he bei,
10 Dao chu dou you hua rong ming mei.
11 Lai hui hui shou, zai diao ge tou,
12 Wu xian chun guang zai wo xiong.
13 Cong jing cheng, dao yuan ye,
14 Dao chu dou you sheng de xi yue.
15 Lai hui hui shou, zai yan ran huang ge tou,
16 Wu xian CHUN GUANG XIAN ZU GUO!!!
17 Tao hua kai yo li hua kai, Jiong xian mei mei dong qi lai;
18 Tao hua kai yo li hua kai, Jie jie mei mei tiao qi lai.
19 Gei ni zi ji, chun yi mai huai chun yi man huai yi ya yo;
20 Gei xin shang ren, chun se man kai chun se man kai.
21 Tao hua kai yo li hua kai, Jie jie mei mei dong qi lai;
22 Tao hua kai yo li hua kai, Jie jie mei mei tiao qi lai.
23 Gei tong bao men, chun yi man huai, hai hai yo;
24 Gei zhe da di, chun se quan kai!!!
25 Cong na nu jiang nan, dao mo he bei,
26 Dao chu dou you hua rong ming mei.
27 Lai hui hui shou, zai diao ge tou,
28 Wu xian chun guang zai wo xiong.
29 Cong jing cheng, dao yuan ye,
30 Dao chu dou you sheng de xi yue.
31 Lai hui hui shou, zai yan ran huang ge tou,
32 Wu xian CHUN GUANG XIAN ZU GUO!!!
33 Lai hui hui shou, zai yan ran huang ge tou,
34 Wu xian CHUN GUANG XIAN ZU GUO!!!
Notes
Data Range and Constraints
For all data, the total number of characters in the input text file (including newline characters) is guaranteed to be no more than $2 \times 10^4$. Also, the input data is guaranteed to be valid.
During evaluation, trailing spaces at the end of lines and the newline at the end of the file in the contestant's output will be ignored. Therefore, contestants can decide whether to output extra spaces at the end of lines. Contestants using Java or Python should pay attention to the efficiency of input and output.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分