-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1158.cpp
55 lines (52 loc) · 795 Bytes
/
1158.cpp
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 <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#pragma warning(disable:4996)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
int list[5001] = { 0, };
int n, k;
int where = 1;
void move() {
for (int i = 1; i <= k - 1; i++) {
if (list[where] == 1) {
i--;
}
where++;
if (where > n) {
where = 1;
}
}
while (list[where] == 1) {
where++;
if (where > n) {
where = 1;
}
}
printf("%d", where);
list[where++] = 1;
if (where > n) {
where = 1;
}
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
int del = 0;
printf("<");
while (del != n-1) {
move();
printf(", ");
del++;
}
move();
printf(">");
return 0;
}