/home/toolbox/public_html/solutions/101/10190/x.cpp
1 #include <stdio.h>
2 int main()
3 {
4 int m, n, i;
5 while(scanf("%d %d", &m, &n) == 2)
6 {
7 if(n < 2 || m == 0 || m < n)
8 {
9 puts("Boring!");
10 continue;
11 }
12 int ans[100] = {m};
13 for(i = 1; ; i++)
14 {
15 if(ans[i-1] == 1)
16 break;
17 if(ans[i-1]%n)
18 {
19 i = -1;
20 break;
21 }
22 ans[i] = ans[i-1]/n;
23 }
24 if(i < 0) puts("Boring!");
25 else
26 {
27 printf("%d", ans[0]);
28 for(m = 1; m < i; m++)
29 printf(" %d", ans[m]);
30 puts("");
31 }
32 }
33 return 0;
34 }
35