/home/toolbox/public_html/solutions/103/10346/a.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:
19 * Date:
20 * Purpose:
21 * Problem:
22 */
23
24 /*
25 * This template reads lines of data at a time until end of file.
26 */
27
28 int n;
29 int k;
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 = 0 <= scanf(" %d %d ", &n, &k);
47 return (dataReadFlag);
48 } /* FUNCTION getInput */
49
50 void process()
51 {
52 /* FUNCTION process */
53 int tot;
54 int left;
55
56 tot = n + (n / k);
57 left = (n / k) + (n % k);
58 while (k <= left)
59 {
60 /* while */
61 tot = tot + (left / k);
62 left = (left % k) + (left / k);
63 } /* while */
64 printf("%d\n", tot);
65
66 } /* FUNCTION process */
67
68 int main()
69 {
70 /* main */
71 int moreToDo;
72
73 init();
74 moreToDo = getInput();
75 while (moreToDo)
76 {
77 /* while */
78 process();
79 moreToDo = getInput();
80 } /* while */
81
82 return EXIT_SUCCESS;
83 } /* main */
84