forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path137.cpp
More file actions
42 lines (38 loc) · 634 Bytes
/
137.cpp
File metadata and controls
42 lines (38 loc) · 634 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
//ac
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int mm[1000], visited[1000];
int main() {
int n, k;
scanf("%d %d", &n, &k);
memset(visited, 0, sizeof(visited));
int a = k / n;
for (int i = 0; i < n; ++i) {
mm[i] = a;
}
mm[0]--, mm[n - 1]++;
a = k % n;
int t = 0;
while (1) {
if ((a * t) % n == n - 1) break;
++t;
}
a = 0;
while (1) {
if (a == n - 1) break;
if (visited[a]) break;
mm[a]++;
visited[a] = 1;
a += t;
while (a >= n) a -= n;
}
for (int i = 0; i < n; ++i) {
if (i) printf(" ");
printf("%d", mm[i]);
}
printf("\n");
return 0;
}