#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ floor(double);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, double *, double *);
int main() {
  double n, k;
  while (EOF != scanf("%lf %lf", &n, &k))
    printf("%d\n", (int)floor((n * k - 1.0) / (k - 1.0)));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11b8 <main+0x88>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe81(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe68(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2ea3(%rip),%r13
mov    0x0(%r13),%rbx
lea    0xeb8(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
cmp    %rax,%rbx
je     11ca <main+0x9a>
lea    0xea5(%rip),%r14
lea    0xe96(%rip),%r15
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe68(%rip),%xmm2
addsd  %xmm2,%xmm0
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x0(%r13),%rbp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
cmp    %rax,%rbp
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
br label %4
4: ; preds = %8, %0
%5 = load i64, i64* @EOF
%6 = call i64 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %2, double* %3)
%7 = icmp ne i64 %5, %6
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = load double, double* %2
%10 = load double, double* %3
%11 = call double @llvm.fmuladd.f64(double %9, double %10, double -1.000000e+00)
%12 = load double, double* %3
%13 = fsub double %12, 1.000000e+00
%14 = fdiv double %11, %13
%15 = call i64 @floor(double %14)
%16 = trunc i64 %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %4
18: ; preds = %4
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = load i64, i64* @EOF
%6 = call i64 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %1, double* %2)
%7 = icmp eq i64 %5, %6
br i1 %7, label %20, label %8
8: ; preds = %0, %8
%9 = load double, double* %1
%10 = load double, double* %2
%11 = call double @llvm.fmuladd.f64(double %9, double %10, double -1.000000e+00)
%12 = fadd double %10, -1.000000e+00
%13 = fdiv double %11, %12
%14 = call i64 @floor(double %13)
%15 = trunc i64 %14 to i32
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i64, i64* @EOF
%18 = call i64 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %1, double* %2)
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %8
20: ; preds = %8, %0
ret i32 0
}