-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuva-10190.cpp
49 lines (37 loc) · 927 Bytes
/
uva-10190.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
#include <bits/stdc++.h>
using namespace std;
vector<int>series;
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
int n, m, i;
bool boring;
while (scanf("%d%d", &n, &m) != EOF) {
if (!n || !m || (n == 1 && m == 1) || n < m || (n > 1 && m == 1)) {
printf("Boring!\n");
continue;
}
series.clear();
boring = false;
while (n != 1) {
if (n % m != 0) {
boring = true;
break;
}
series.push_back(n);
n /= m;
}
if (boring) {
printf("Boring!\n");
}
else {
n = series.size();
for (i = 0; i < n; i++) {
printf("%d ", series[i]);
}
printf("1\n");
}
}
return 0;
}