-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHDU_2015.cpp
More file actions
55 lines (55 loc) · 729 Bytes
/
HDU_2015.cpp
File metadata and controls
55 lines (55 loc) · 729 Bytes
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
#include <iostream>
using namespace std;
/*
void Quick_Sort(double A[],int p,int r)
{
if (p>=r)
return ;
int value = A[r];
int i = p-1;
int temp;
for (int j=p;j<r;j++)
{
if (A[j]<value)
{
i++;
temp = A[i];
A[i] = A[j];
A[j] = temp;
}
}
i++;
A[r] = A[i];
A[i] = value;
Quick_Sort(A,p,i-1);
Quick_Sort(A,i+1,r);
}*/
int main()
{
int n,m;
int length,remainder;
while (cin>>n>>m)
{
int sum = 0;
int a=m+1;
length = n/m;
remainder = n%m;
cout << a;
for (int i=1;i<length;i++)
{
a += 2*m;
cout << " " << a;
}
if (remainder != 0)
{
for (int j=m*length+1;j<=n;j++)
{
sum += 2*j;
}
sum = sum/remainder;
cout <<" " <<sum;
}
cout << endl;
}
return 0;
}