Day1

Day1

今天学习的是sort + 结构体 + 简单数学 + 暴力
比较菜,学习的比较慢,勉强能掌握


OJ链接:https://cn.vjudge.net/contest/312050
从这个OJ开始,往后的OJ链接只需要在网上
输入每个题的名称就能找到对应的OJ

前m大的数

Problem Description
还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。
给定一个包含N(N<=3000)个正整数的序列,每个数不超过5000,对它们两两相加得到的N*(N-1)/2个和,求出其中前M大的数(M<=1000)并按从大到小的顺序排列。

Input
输入可能包含多组数据,其中每组数据包括两行:
第一行两个数N和M,
第二行N个数,表示该序列。

Output
对于输入的每组数据,输出M个数,表示结果。输出应当按照从大到小的顺序排列。

Sample Input

1
2
3
4
4 4
1 2 3 4
4 5
5 3 6 4

Sample Output

1
2
7 6 5 5
11 10 9 9 8

Solve:直接开大数组,暴力

code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
int cmp(int a, int b)
{
return a b;
}
int n, m;
int a[3001];
int b[5000000];
int main()
{

while(scanf("%d %d",&n, &m)!=EOF)
{
for(int i = 0; i < n; i ++)
{
cin >a[i];
}
int t = 0;
sort(a, a + n, cmp);
int ans = 0;
for(int i = ans + 1; i < n; i ++)
{
b[t ++] = a[i] + a[ans];
if(i == n - 1 && ans != n )
{
i = ans + 1;
ans ++;
}
}
sort(b, b + t, cmp);
for(int i = 0; i < m; i ++)
{
if(i == 0) cout << b[0];
else cout << ' ' << b[i];
}
cout << endl;
}
return 0;
}

稳定排序

Problem Description
大家都知道,快速排序是不稳定的排序方法。
如果对于数组中出现的任意a[i],aj,其中a[i]==a[j],在进行排序以后a[i]一定出现在a[j]之前,则认为该排序是稳定的。
某高校招生办得到一份成绩列表,上面记录了考生名字和考生成绩。并且对其使用了某排序算法按成绩进行递减排序。现在请你判断一下该排序算法是否正确,如果正确的话,则判断该排序算法是否为稳定的。

Input
本题目包含多组输入,请处理到文件结束。
对于每组数据,第一行有一个正整数N(0<N<300),代表成绩列表中的考生数目。
接下来有N行,每一行有一个字符串代表考生名字(长度不超过50,仅包含’a’~’z’),和一个整数代表考生分数(小于500)。其中名字和成绩用一个空格隔开。
再接下来又有N行,是上述列表经过某排序算法以后生成的一个序列。格式同上。

Output
对于每组数据,如果算法是正确并且稳定的,就在一行里面输出”Right”。如果算法是正确的但不是稳定的,就在一行里面输出”Not Stable”,并且在下面输出正确稳定排序的列表,格式同输入。如果该算法是错误的,就在一行里面输出”Error”,并且在下面输出正确稳定排序的列表,格式同输入。
注意,本题目不考虑该排序算法是错误的,但结果是正确的这样的意外情况。

Sample Input

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
3
aa 10
bb 10
cc 20
cc 20
bb 10
aa 10
3
aa 10
bb 10
cc 20
cc 20
aa 10
bb 10
3
aa 10
bb 10
cc 20
aa 10
bb 10
cc 20

Sample Output

1
2
3
4
5
6
7
8
9
Not Stable
cc 20
aa 10
bb 10
Right
Error
cc 20
aa 10
bb 10

Solve: 看清题意,慢慢理清思路
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<bits/stdc++.h>
using namespace std;
struct node{
string name;
int sorce, id;
}stu[301], stu_1[301];
//比较函数,若分数相同,则先出现的标记并按递增的方式排序
int cmp1(node a,node b)
{
if(a.sorce == b.sorce) return a.id < b.id;
return a.sorce b.sorce;
}

int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i = 0; i < n; i ++)
{
cin >stu[i].name >stu[i].sorce;
stu[i].id = i;
}
for(int i = 0; i < n; i ++)
{
cin >stu_1[i].name >stu_1[i].sorce;
}
//正确排序首先给出的序列
sort(stu, stu + n, cmp1);
int flag = 0; //做标记
for(int i = 0; i < n - 1; i ++)
{
//这个是经过体面意思排序过的,直接通过分数的排序判断是否稳定
if(stu_1[i].sorce < stu_1[i + 1].sorce)
{
flag = 1;//表示错误
break;
}
}
if(flag)
{
puts("Error");
for(int i = 0; i < n; i ++)
{
cout << stu[i].name << " " << stu[i].sorce << endl;
}
}
else
{
//判断是否稳定
for(int i = 0; i < n; i ++)
{
if(stu[i].name != stu_1[i].name)
{
flag = 1;//不稳定
break;
}
}
if(flag)
{
puts("Not Stable");
for(int i = 0; i < n; i ++)
{
cout << stu[i].name << " " << stu[i].sorce << endl;
}
}
else
{
puts("Right");
}
}
}

return 0;
}

开门人和关门人

Problem Description
每天第一个到机房的人要把门打开,最后一个离开的人要把门关好。现有一堆杂乱的机房签
到、签离记录,请根据记录找出当天开门和关门的人。
Input
测试输入的第一行给出记录的总天数N ( 0 )。下面列出了N天的记录。
每天的记录在第一行给出记录的条目数M ( 0 ),下面是M行,每行的格式为
证件号码 签到时间 签离时间
其中时间按“小时:分钟:秒钟”(各占2位)给出,证件号码是长度不超过15的字符串。
Output
对每一天的记录输出1行,即当天开门和关门人的证件号码,中间用1空格分隔。
注意:在裁判的标准测试输入中,所有记录保证完整,每个人的签到时间在签离时间之前,
且没有多人同时签到或者签离的情况。
Sample Input

1
2
3
4
5
6
7
8
9
10
3
1
ME3021112225321 00:00:00 23:59:59
2
EE301218 08:05:35 20:56:35
MA301134 12:35:45 21:40:42
3
CS301111 15:30:28 17:00:10
SC3021234 08:00:00 11:25:25
CS301133 21:45:00 21:58:40

Sample Output

1
2
3
ME3021112225321 ME3021112225321
EE301218 MA301134
SC3021234 CS301133

Solve: 注意时间的转化
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<bits/stdc++.h>
using namespace std;
struct node{
char name[20];
int s_hour,s_min,s_sec;
int e_hour,e_min,e_sec;
int s, e;
}a[1000];
int cmp1(node a, node b)
{
return a.s < b.s;
}
int cmp2(node a, node b)
{
return a.e b.e;
}
int main()
{
int n, m;
cin >n;
while(n --)
{
cin >m;
for(int i = 0; i < m; i ++)
{
scanf("%s %d:%d:%d %d:%d:%d",&a[i].name, &a[i].s_hour,&a[i].s_min,&a[i].s_sec, &a[i].e_hour, &a[i].e_min, &a[i].e_sec);
a[i].s = a[i].s_hour * 3600 + a[i].s_min * 60 + a[i].s_sec;
a[i].e = a[i].e_hour * 3600 + a[i].e_min * 60 + a[i].e_sec;
}
sort(a, a + m, cmp1);
cout << a[0].name << ' ';
sort(a, a + m, cmp2);
cout << a[0].name << endl;
}
return 0;
}

EXCEL排序

Problem Description
Excel可以对一组纪录按任意指定列排序。现请你编写程序实现类似功能。
Input
测试输入包含若干测试用例。每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号。以下有 N
行,每行包含一条学生纪录。每条学生纪录由学号(6位数字,同组测试中没有重复的学号)、姓名(不超过8位且不包含空格的字符串)、成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开。当读到 N=0 时,全部输入结束,相应的结果不要输出。
Output
对每个测试用例,首先输出1行“Case i:”,其中 i 是测试用例的编号(从1开始)。随后在 N 行中输出按要求排序后的结果,即:当 C=1 时,按学号递增排序;当 C=2时,按姓名的非递减字典序排序;当 C=3
时,按成绩的非递减排序。当若干学生具有相同姓名或者相同成绩时,则按他们的学号递增排序。
Sample Input

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
3 1
000007 James 85
000010 Amy 90
000001 Zoe 60
4 2
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 98
4 3
000007 James 85
000010 Amy 90
000001 Zoe 60
000002 James 90
0 0

Sample Output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Case 1:
000001 Zoe 60
000007 James 85
000010 Amy 90
Case 2:
000010 Amy 90
000002 James 98
000007 James 85
000001 Zoe 60
Case 3:
000001 Zoe 60
000007 James 85
000002 James 90
000010 Amy 90

Solve:仔细读题,看清题意在写
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<bits/stdc++.h>
using namespace std;

struct node{
string number;
string name;
int sorce;
}stu[100001];

bool cmp1(node x, node y)
{
return x.number < y.number;
}
bool cmp2(node x, node y)
{
if(x.name == y.name) return x.number < y.number;
return x.name < y.name;
}
bool cmp3(node x, node y)
{
if(x.sorce == y.sorce) return x.number < y.number;
return x.sorce < y.sorce;
}


int main()
{
int n, c;
int t = 1;
while(scanf("%d %d",&n, &c)!=EOF)
{
if(n == 0 && c == 0) break;
for(int i = 0; i < n; i ++)
{
cin >stu[i].number >stu[i].name >stu[i].sorce;
}
if(c == 1) sort(stu, stu + n, cmp1);
// if(c == 1) sort(stu.number.begin(), stu.number.end()); string特定的排序方式
else if(c == 2) sort(stu, stu + n, cmp2);
else if(c == 3) sort(stu, stu + n, cmp3);
printf("Case %d:\n",t ++);
for(int i = 0; i < n; i ++)
{
cout << stu[i].number << ' ' << stu[i].name<< ' ' << stu[i].sorce << endl;
}
}

return 0;
}

统计同成绩学生人数

Problem Description
读入N名学生的成绩,将获得某一给定分数的学生人数输出。
Input
测试输入包含若干测试用例,每个测试用例的格式为
第1行:N
第2行:N名学生的成绩,相邻两数字用一个空格间隔。
第3行:给定分数

当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。
Output
对每个测试用例,将获得给定分数的学生人数输出。
Sample Input

1
2
3
4
5
6
7
8
9
10
3
80 60 90
60
2
85 66
0
5
60 75 90 55 75
75
0

Sample Output

1
2
3
1
0
2

Solve:简单题
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, m;

int a[1001];
while(scanf("%d",&n)!=EOF)
{
int ans = 0;
if(n == 0) break;
for(int i = 0; i < n; i ++)
{
cin >a[i];
}
cin >m;
for(int i = 0; i < n ; i ++)
{
if(a[i] == m) ans ++;
}
cout << ans << endl;
}
return 0;
}

What Is Your Grade?

Problem Description

“Point, point, life of student!”
This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.
There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50.
Note, only 1 student will get the score 95 when 3 students have solved 4 problems.
I wish you all can pass the exam!
Come on!
Input
Input contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p.
A test case starting with a negative integer terminates the input and this test case should not to be processed.
Output
Output the scores of N students in N lines for each case, and there is a blank line after each case.
Sample Input

1
2
3
4
5
6
7
8
4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1

Sample Output

1
2
3
4
5
6
100
90
90
95

100

Solve:仔细理解题意,认真写
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//第一种
//#include <iostream>
//#include<cstdio>
//#include<cstring>
//#include<algorithm>
//using namespace std;
//struct node
//{
// int x;
// char s[10];
//}a[101];
//int main()
//{
// int n;
// while(scanf("%d",&n),n!=-1)
// {
// for(int i=0;i<n;i++)
// scanf("%d %s",&a[i].x,a[i].s);
// int t[5]={0};
// for(int i=4;i>0;i--)//做出相同题数的人的个数
// {
// for(int j=0;j<n;j++)
// {
// if(a[j].x==i) t[i]++;
// }
// }
// for(int i=0;i<n;i++)
// {
// if(a[i].x==5) printf("100\n");
// else if (a[i].x==0) printf("50\n");
// else
// {
// int k=0;
// for(int j=0;j<n;j++)
// {
// if(a[j].x==a[i].x&&strcmp(a[j].s,a[i].s)<0)
////头文件是string,实质就是a[j].s<a[i].s
// k++;
// }
// if(k>=t[a[i].x]/2)
////相同题数用时短的人数做出相同题数的总人数一半
// printf("%d\n",100-(5-a[i].x)*10);
// else
// printf("%d\n",100-(5-a[i].x)*10+5);
// }
// }
// printf("\n");
// }
// return 0;
//}
//第二种
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct ssq
{
int x;
char t[20];
int fs;
}sq[1005];
int main()
{
int n;
while(~scanf("%d",&n)&&n>0)
{
int s[10],ss[10];
memset(s,0,sizeof(s));
memset(ss,0,sizeof(ss));
for(int i=0;i<n;i++)
{
scanf("%d %s",&sq[i].x,sq[i].t);
s[sq[i].x]++;//记录做完题数对应数量人数
sq[i].fs=0;//分数归0
}
for(int i=0;i<n;i++)//遍历结构体
{
if(sq[i].x==5)//特殊处理5题
sq[i].fs=100;
else if(sq[i].x==0)//特殊处理0题
sq[i].fs=50;
else
{
if(s[sq[i].x]==1)//特殊处理做对1题
sq[i].fs=(sq[i].x*10+55);
else if(ss[sq[i].x]<s[sq[i].x]/2&&sq[i].fs==0)//找出本题数中最小耗时
{
int v=i;//记录位置当前
for(int j=0;j<n;j++)
{
if(sq[j].fs==0&&sq[j].x==sq[v].x&&strcmp(sq[j].t,sq[v].t)<0)//更改最小耗时位置
v=j;
}
ss[sq[i].x]++;//记录已经找出的最小耗时人数
sq[v].fs=55+sq[v].x*10;//更改分数
}
}
}
for(int i=0;i<n;i++)
{
if(sq[i].fs!=0)
printf("%d\n",sq[i].fs);
else
printf("%d\n",sq[i].x*10+50);//没有分值的赋基础分值
}
printf("\n");

}
return 0;
}

Magical Bamboos

Problem Description
In a magical forest, there exists N bamboos that don’t quite get cut down the way you would expect.
Originally, the height of the ith bamboo is equal to hi. In one move, you can push down a bamboo and decrease its height by one, but this move magically causes all the other bamboos to increase in height by one.
If you can do as many moves as you like, is it possible to make all the bamboos have the same height?
Input
The first line of input is T – the number of test cases.
The first line of each test case contains an integer N (1 ≤ N ≤ 105) - the number of bamboos.
The second line contains N space-separated integers hi (1 ≤ hi ≤ 105) - the original heights of the bamboos.
Output
For each test case, output on a single line “yes” (without quotes), if you can make all the bamboos have the same height, and “no” otherwise.
Input

1
2
3
4
5
2
3
2 4 2
2
1 2

Output

1
2
yes
no

Solve:找规律
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<bits/stdc++.h>
using namespace std;
int a[1000007];
int main()
{
int n, m;
scanf("%d",&n);
while(n --)
{
scanf("%d",&m);
int t = 0;
for(int i = 0; i < m; i ++)
{
scanf("%d",&a[i]);
}
for(int i = 0; i < m - 1; i ++)
{
if((a[i + 1] - a[i]) % 2 != 0)
{
t = 1;
break;
}
}

if(t == 1) printf("no\n");
else printf("yes\n");
}
return 0;
}

Bear and Three Balls

Problem Description

Limak is a little polar bear. He has n balls, the i-th ball has size ti.
Limak wants to give one ball to each of his three friends. Giving gifts isn’t easy — there are two rules Limak must obey to make friends happy:
No two friends can get balls of the same size.
No two friends can get balls of sizes that differ by more than 2.
For example, Limak can choose balls with sizes 4, 5 and 3, or balls with sizes 90, 91 and 92. But he can’t choose balls with sizes 5, 5 and 6 (two friends would get balls of the same size), and he can’t choose balls with sizes 30, 31 and 33 (because sizes 30 and 33 differ by more than 2).
Your task is to check whether Limak can choose three balls that satisfy conditions above.
Input
The first line of the input contains one integer n (3 ≤ n ≤ 50) — the number of balls Limak has.
The second line contains n integers t1, t2, …, tn (1 ≤ ti ≤ 1000) where ti denotes the size of the i-th ball.
Output
Print “YES” (without quotes) if Limak can choose three balls of distinct sizes, such that any two of them differ by no more than 2. Otherwise, print “NO” (without quotes).
Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Input
4
18 55 16 17
Output
YES
Input
6
40 41 43 44 44 44
Output
NO
Input
8
5 972 3 4 1 4 970 971
Output
YES

1
2
3
4
5
6
Note
In the first sample, there are 4 balls and Limak is able to choose three of them to satisfy the rules. He must must choose balls with sizes 18, 16 and 17.
In the second sample, there is no way to give gifts to three friends without breaking the rules.
In the third sample, there is even more than one way to choose balls:
Choose balls with sizes 3, 4 and 5.
Choose balls with sizes 972, 970, 971.

Solve:找规律
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
int a[100001], b[100001];
while(scanf("%d",&n)!=EOF)
{
int ans = 0;
int t = 1;
for(int i = 0; i < n; i ++)
{
cin >a[i];
}
sort(a, a + n);


for(int i = 0; i < n; i ++)
{
if(binary_search(a, a + n, a[i] + 1) && binary_search(a, a + n, a[i] + 2))
{
ans = 1;
break;
}
}
if(ans == 1) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}

今年暑假不AC

Problem Description

1
2
3
4
5
6
7
8
“今年暑假不AC?”
“是的。”
“那你干什么呢?”
“看世界杯呀,笨蛋!”
“@#$%^&*%...”

确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。
作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目)

Input
输入数据包含多个测试实例,每个测试实例的第一行只有一个整数n(n<=100),表示你喜欢看的节目的总数,然后是n行数据,每行包括两个数据Ti_s,Ti_e (1<=i<=n),分别表示第i个节目的开始和结束时间,为了简化问题,每个时间都用一个正整数表示。n=0表示输入结束,不做处理。
Output
对于每个测试实例,输出能完整看到的电视节目的个数,每个测试实例的输出占一行。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Sample Input
12
1 3
3 4
0 7
3 8
15 19
15 20
10 15
8 18
6 12
5 10
4 14
2 9
0
Sample Output
5

Solve:头尾对接
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
using namespace std;

struct node{
int start, end;
}g[101];

int cmp(node x, node y)
{
return x.end < y.end;
}

int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n == 0) break;
int ans = 1;
for(int i = 0; i < n; i ++)
{
cin >g[i].start >g[i].end;
}
sort(g, g + n, cmp);
int s = g[0].end;
for(int i = 1;i < n; i ++)
{
if(g[i].start >= s)
{
ans ++;
s = g[i].end;
}
}
cout << ans << endl;
}

return 0;
}

The sum problem

Problem Description
Given a sequence 1,2,3,……N, your job is to calculate all the possible sub-sequences that the sum of the sub-sequence is M.
Input
Input contains multiple test cases. each case contains two integers N, M( 1 <= N, M <= 1000000000).input ends with N = M = 0.
Output
For each test case, print all the possible sub-sequence that its sum is M.The format is show in the sample below.print a blank line after each test case.

1
2
3
4
5
6
7
8
9
10
11
12
Sample Input
20 10
50 30
0 0
Sample Output
[1,4]
[10,10]

[4,8]
[6,9]
[9,11]
[30,30]

Solve:找规律,数学思维
code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<bits/stdc++.h>
using namespace std;

int main()
{
int n, m;

while(scanf("%d %d",&n, &m)!=EOF)
{
if(n == 0 && m == 0) break;
for(int i = sqrt(2 * m); i >= 1; i --)
{
//s = a1 * i + i * (i - 1) / 2;
int a1 = (m - i * (i - 1) / 2) / i;
if((a1 * i) + i * (i - 1) / 2 == m)
printf("[%d,%d]\n",a1, a1 + i - 1);
}
puts("");

}

return 0;
}

---------------- The End ----------------
0%