/home/toolbox/public_html/solutions/101/10190/b.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 #define MAX_LINE 257
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2021-01-14
20 * Purpose: fun
21 * Problem: 10190 - Divide, But Not Quite Conquer!
22 */
23
24 /*
25 * This template reads lines of data at a time until end of file.
26 */
27
28 int n;
29 int m;
30
31 void init()
32 {
33 /* FUNCTION init */
34 } /* FUNCTION init */
35
36 void dump()
37 {
38 /* FUNCTION dump */
39 } /* FUNCTION dump */
40
41 int getInput()
42 {
43 /* FUNCTION getInput */
44 int dataReadFlag;
45
46 dataReadFlag = (2 == scanf(" %d %d ", &n, &m));
47 return (dataReadFlag);
48 } /* FUNCTION getInput */
49
50 void process()
51 {
52 /* FUNCTION process */
53 int tmp;
54 int valid = TRUE;
55
56 tmp = n;
57 if ((n < m) || (2 > n) || (2 > m))
58 {
59 /* bad case */
60 printf("Boring!\n");
61 } /* bad case */
62 else
63 {
64 /* normal cases */
65 while ((valid) && (tmp > m))
66 {
67 /* while */
68 tmp = tmp / m;
69 valid = 0 == (tmp % m);
70 } /* while */
71 if (valid)
72 {
73 /* valid */
74 tmp = n;
75 while (tmp > m)
76 {
77 /* while */
78 printf("%d ", tmp);
79 tmp = tmp / m;
80 } /* while */
81 printf("%d 1\n", m);
82 } /* valid */
83 else
84 {
85 /* invalid */
86 printf("Boring!\n");
87 } /* invalid */
88 } /* normal cases */
89 } /* FUNCTION process */
90
91 int main()
92 {
93 /* main */
94 int moreToDo;
95
96 init();
97 moreToDo = getInput();
98 while (moreToDo)
99 {
100 /* while */
101 process();
102 moreToDo = getInput();
103 } /* while */
104 return EXIT_SUCCESS;
105 } /* main */
106