luogu#P8871. [传智杯 #5 初赛] C-莲子的排版设计学
[传智杯 #5 初赛] C-莲子的排版设计学
题目背景
你现在不能休息,周围有 deadline 在游荡。
莲子正在赶自己的程序设计作业。除了完成程序代码的编写,对提交上去的作业进行排版以对助教留下良好印象同样重要。
而众所周知,文章里面的代码和一些特殊性质的文本是要附上行号的,然而它们的篇幅往往都很长,手动去加容易出现失误。因此,莲子决定自力更生造轮子,写一个行号生成器。
题目描述
莲子希望实现这样一个功能:输入一份文本文件,并给该文件加上行号。
以下是本题中三个基本概念的定义:
- 文本字符由 中所有的可视字符,以及空格()组成。
- 一行字符由若干个(可以为 个)文本字符,以及在末尾恰好一个换行符()组成。
- 文本文件由若干个(至少为 个)一行字符组成。文本文件的行数就是组成它的行的数量。
以下是本题中添加行号的方法:
- 设该文本文件一共有 行。设正整数 的字宽为 。那么,在每一行的开头会有 的长度用来显示行号。
- 对于第 行,假设 的字宽为 ,那么这一行行号将会显示为 $\underbrace{\texttt{␣␣...␣}}_{s-t\text{ 个}}\ i\ \texttt{␣}$,其中 表示空格。
以下是一个例子:
$$\boxed{\begin{aligned} &\verb!#include为了便于读者观察,这里将所有的空格换成用来表示空格的 字符。
$$\boxed{\begin{aligned} &\verb!#include输入格式
输入包含若干行,为原始的文本文件。
输出格式
输出包含若干行,为加上行号后的文本文件。
#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;
}
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 }
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);
}
}
}
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 }
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!!!
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!!!
提示
数据范围及约定
对于全部数据,保证输入的文本文件的字符总数(包括换行符在内),不超过 。同时,保证输入数据合法。
评测时,会忽略选手输出文件的行末空格与文末换行。因此选手可以自行决定行尾是否要输出多余空格。请使用 Java 或 Python 语言作答的选手注意输入输出时的效率。