Problem:
 Score : 300 points    Problem Statement There is a sequence of length N : A_1, A_2, ..., A_N . Initially, this sequence is a permutation of 1, 2, ..., N .  On this sequence, Snuke can perform the following operation:   Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.   Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.      Constraints  2 \leq K \leq N \leq 100000  A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N .         Input Input is given from Standard Input in the following format:  N  K  A_1  A_2  ...  A_N       Output Print the minimum number of operations required.        Sample Input 1 4 3
2 3 1 4      Sample Output 1 2  One optimal strategy is as follows:    In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4 .    In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1 .         Sample Input 2 3 3
1 2 3      Sample Output 2 1       Sample Input 3 8 3
7 3 1 8 4 6 2 5      Sample Output 3 4

Solution (Python):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-chk-1
ans=((l+k-1)//k)+((r+k-1)//k)

if l%k==0:
    t1=0
else:
    t1=k-(l%k)
ans=min(ans,((l+k-1)//k)+((r-t1+k-1)//k))

if r%k==0:
    t2=0
else:
    t2=k-(r%k)
ans=min(ans,((l-t2+k-1)//k)+((r+k-1)//k))
print(ans)

Solution (Python):
n, k = map(int, input().split())
a = k
ret = 1
while n > a:
    a += (k - 1)
    ret += 1    
print(ret)

Solution (Python):
iN,iK = [int(_) for  _ in  input().split()]

def fCeil(n,k):
    if n % k :
        return n // k + 1
    else:
        return n // k
print(fCeil(iN-1,(iK-1)))

Solution (Python):
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

i1 = A.index(1)
d1, m1 = divmod(i1, K - 1)

r = i1 + 1
if m1 != 0:
    r += K - 1 - m1

d2, m2 = divmod(max(0, N - r), K - 1)

print(d1 + d2 + (m1 != 0) + (m2 != 0))

Solution (Python):
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
print(-(-(N - 1) // (K - 1)))

Solution (Python):
import sys
import string
input=sys.stdin.readline

n,k=map(int,input().split())
l=list(map(int,input().split()))
m=n-k
a=0
while m>0:
    m-=k-1
    a+=1
print(a+1)

Solution (Python):
n,k=map(int,input().split())

A=list(map(int,input().split()))

if((n-1)%(k-1)==0):    
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1) + 1)

Solution (Python):
n, k = map(int, input().split())

res = - ((1 - n) // (k-1))

print(res)

Solution (Python):
import math

N, K = map(int, input().split())
print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
import numpy as np
N, K = map(int, input().split())

array = np.array(list(map(int, input().split())))

cnt = 0
sum_ans = K
while True:
    if sum_ans >= N:
        cnt += 1
        break
    else:
        sum_ans += K-1
        cnt += 1

print(cnt)

Solution (Python):
n, k = map(int, input().split())
a = input().split()

a = [int(m) for m in a]
t = a.index(min(a))

leftar = []
rightar = []
leftco = 0
rightco = 0
startco = 1

for i in range(1, k + 1):
    if (t - k + i) / (k - 1) <= 0:
        leftar.append(leftco)
    elif (t - k + i) % (k - 1) == 0:
        p = int((t - k + i) / (k - 1))
        for j in range(1, p + 1):
            leftco += 1
        leftar.append(leftco)
        leftco = 0
    else:
        p = int((t - k + i) / (k - 1)) + 1
        for j in range(1, p + 1):
            leftco += 1
        leftar.append(leftco)
        leftco = 0

for i in range(1, k + 1):
    if (n - t - i) / (k - 1) <= 0:
        rightar.append(rightco)
    if (n - t - i) % (k - 1) == 0:
        q = int((n - t - i) / (k - 1))
        for j in range(1, q + 1):
            rightco += 1
        rightar.append(rightco)
        rightco = 0
    else:
        q = int((n - t - i) / (k - 1)) + 1
        for j in range(1, q + 1):
            rightco += 1
        rightar.append(rightco)
        rightco = 0

sumar = [x + y + startco for (x, y) in zip(leftar, rightar)]

print(min(sumar))

Solution (Python):
(n, k) = map(int, input().split())
_ = input()
count = 0

while n > k:
    n -= k - 1
    count += 1

count += 1
print(count)

Solution (Python):
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
count = 0

while n > k:
    n -= k - 1
    count += 1

count += 1
print(count)

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))
print((N - 2) // (K - 1) + 1)

Solution (Python):

from math import ceil
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(ceil((n-1)/(k-1)))

Solution (Python):
n,k=map(int,input().split())     
a=list(map(int,input().split())) 
if (n-1)%(k-1)==0:               
    print((n-1)//(k-1))          
else:                            
    print((n-1)//(k-1)+1)

Solution (Python):
import sys


n, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]

if k == 2:
    print(n-1)
    sys.exit()

if (n % (k-1)) <= 1:
    ans = n // (k-1)
else:
    ans = (n // (k-1)) + 1
print(ans)

Solution (Python):


n, k = [int(x) for x in input().split()]
alist = [int(x) for x in input().split()]
ans = int((n-1) / (k-1))
if (n-1) % (k-1) != 0:
    ans += 1
print(ans)

Solution (Python):
n,k = map(int,input().split())
a = list(map(int,input().split()))
if (n - 1) % (k - 1) == 0:
  print((n-1) // (k-1))
else:
  print((n-1) // (k-1) + 1)

Solution (Python):
n,k = map(int,input().split())
print((n-1)//(k-1) + ((n-1)%(k-1) > 0))

Solution (Python):
N,K=list(map(int, input().split()))
Q=0
print((N-1)//(K-1)+((N-1)%(K-1)>0))

Solution (Python):
N,K = [int(i) for i in input().split()]
print(-(-(N-1)//(K-1)))

Solution (Python):
N,K = map(int,input().split(" "))
if (N-1) % (K-1) == 0:
    print(int((N-1)/(K-1)))
else:
    print(int((N-1)/(K-1))+1)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))

if N == K:
    print(1)
elif N / 2 < K:
    print(2)
else:
    ans = 1
    num = 0
    num += K
    while num < N:
        num += K - 1
        ans += 1
    print(ans)

Solution (Python):



def main():
    from math import ceil

    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    print(ceil((n - 1) / (k - 1)))


if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))

print((N+K-3) // (K-1))

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
count = 1
A_len = N - K

while A_len > 0:
    A_len -= K - 1
    count += 1

print(count)

Solution (Python):
import math

n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

print(math.ceil((n - 1) / (k - 1)))

Solution (Python):
N,K = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0

res = len(a)

while True:
	if res <= 1:
		print(cnt)
		exit()
	res = res - (K-1)
	cnt += 1

Solution (Python):
import math

N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = math.ceil((N - 1) / (K - 1))
print(ans)

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 1
ans += ((n - k) + (k - 2)) // (k - 1)
print(ans)

Solution (Python):
n, k = map(int, input().split())
listA = list(map(int, input().split()))
count =0
n -=k
count +=1
if n%(k-1)==0:
    count+=n//(k-1)
else:
    count+=n//(k-1)
    count+=1
print(count)

Solution (Python):
n, k = map(int, input().split())
num = list(map(int, input().split()))

cnt = 0
while n > 1:
    n -= k-1
    cnt += 1

print(cnt)

Solution (Python):
n,k=map(int,input().split())
input()
if (n-1)%(k-1)==0:print((n-1)//(k-1))
else:print((n-1)//(k-1)+1)

Solution (Python):
from math import ceil

if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    seq = list(map(int, input().split()))

    print(ceil((N-1) / (K-1)))

Solution (Python):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
print(-(-(N-1) // (K-1)))

Solution (Python):

N, K = map(int, input().split())
A = list(map(int, input().split()))

minA = min(A)
toflat = N - A.count(minA)

print(-(-toflat // (K - 1)))

Solution (Python):
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
N, K = map(int, input().split())

list_a = []
for part in input().split():
    list_a.append(int(part))

a_len = len(list_a) - K
cnt = 1
while True:

    if (K-1) <= a_len:
        a_len -= K - 1
        cnt += 1    
    else:
        if a_len != 0:
            cnt += 1
        break

print(cnt)

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))

if (N-1)%(K-1) ==0:
    print((N-1)//(K-1))
else:
    print((N-1)//(K-1)+1)

Solution (Python):

"""
C - Minimization
https://beta.atcoder.jp/contests/abc101/tasks/arc099_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, K, arr):
    ans = 1
    while N > K:
        N -= (K - 1)
        ans += 1
    return ans


def main(args):
    N, K = map(int, input().split())
    arr = [int(a) for a in input().split()]
    ans = solve(N, K, arr)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
n, k  = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
while(n>1):
    n -= (k-1)
    cnt += 1
print(cnt)

Solution (Python):
n, k = list(map(int, input().split(" ")))

print((n - 2) // (k - 1) + 1)

Solution (Python):
N, K = map(int, input().split())
data = input().split()
data_set = set(data)
print((len(data_set)-1)//(K-1) + 1 * bool((len(data_set)-1)%(K-1)))

Solution (Python):


import math


def inpl(): return list(map(int, input().split()))


N, K = inpl()
A = inpl()

print(math.ceil((N - K) / (K - 1)) + 1)

Solution (Python):
n,k=map(int,input().split())
print((n+k-3)//(k-1))

Solution (Python):

N, K = map(int,input().split())

A = list(map(int,input().split()))

print(-(-(N-1)//(K-1)))

Solution (Python):
import math
n,k = map(int,input().split())
input()
print(math.ceil((n-1)/(k-1)))

Solution (Python):


n,k = map(int,raw_input().split())
s = raw_input()

if (n-1)%(k-1) == 0: print (n-1)/(k-1)
else: print (n-1)/(k-1)+1

Solution (Python):
def modnotzero(m, n):
	if m % n != 0: return 1
	else: return 0
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
pos = 0
for i in range(0, N):
	if A == 1: pos = i
left = pos
right = N - 1 - pos

min = N+1

for i in range(0, K):
	L = left - i
	R = right - K + 1 + i
	if L >= 0 and R >= 0:
		cnt = L/(K-1)+R/(K-1)+modnotzero(L, (K-1))+modnotzero(R, (K-1))
		if cnt < min: min = cnt

print min + 1

Solution (Python):
n,k = map(int, input().split())

if (n-1)%(k-1)==0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)

Solution (Python):
import math

n,k = map(int, input().split())
a = list(map(int, input().split()))

ans = math.ceil((n-1)/(k-1))

print(ans)

Solution (Python):

from math import ceil

n,k = list(map(int, input().split()))
A = list(map(int, input().split()))

print(ceil((len(A)-1)/(k-1)))

Solution (Python):
import math
A,B = list(map(int,input().split()))
_ =input()
print(math.ceil((A-B)/(B-1))+1)

Solution (Python):
import math

N, K = map(int, input().split())
A    = list(map(int, input().split()))

print(1+int(math.ceil(((N - K)/(K-1)))))

Solution (Python):
import math

N, K = map(int, input().split())
input()
if K >= N:
    print(1)
else:
    print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

print(ceil((N-1)/(K-1)))

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))
if (N-1)%(K-1) != 0 :
    print((N-1)//(K-1)+1)
else :
    print((N-1)//(K-1))

Solution (Python):
n,k = map(int, input().split())
if n <= k:
    print(1)
else:
    if (n-1)%(k-1)==0:
        print((n-1)//(k-1))
    else:
        print((n-1)//(k-1)+1)

Solution (Python):
N,K = list(map(int,input().split()))
a = (N-1)/(K-1)
print(int(a) + (0 if int(a)==a else 1))

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))
def kiriage(a, b): 
    return (a + b - 1) // b

print(kiriage(N - 1, K - 1))

Solution (Python):
import math

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

answer = math.ceil((N-1)/(K-1))
print(answer)

Solution (Python):
import math

N, K = map(int,input().split())
A = list(map(int,input().split()))
ans = int(math.ceil((N-K)/(K-1))) + 1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10000)


N,K = map(int,input().split())
A = input().split()

tmp = K
count = 1

while tmp < N:
        tmp += K-1
        count += 1

print(count)

Solution (Python):
n,k=map(int,input().split())
A=list(map(int,input().split()))










print(int((n-1-0.1)//(k-1)+1))

Solution (Python):
import numpy as np
N, K = map(int, input().split())
A = [int(i) for i in list(input().split())]

print(int(np.ceil((N-1)/(K-1))))

Solution (Python):
N,K = map(int, input().split())
A = list(map(int, input().split()))

print((N-1)//(K-1) + bool((N-1)%(K-1)))

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))

ans = 1
cover = K
while True:
    if cover >= N:
        print(ans)
        exit()
    cover += K-1
    ans += 1

Solution (Python):
N,K = map(int, input().split())

def f():
  for i in range(1, N+1):
    if (K-1)*i + 1 >= N:
      return i
print(f())

Solution (Python):
N,K = map(int, input().split())
A = list(map(int, input().split()))

def f():
  for i in range(1, N+1):
    if (K-1)*i + 1 >= N:
      return i
print(f())

Solution (Python):
n,k = map(int, input().split())
a = [int(x) for x in input().split()]
ext = k - 1
lest = len(a) - 1
cnt = 0
while lest > 0:
  lest -= ext
  cnt += 1
print(cnt)

Solution (Python):
import math
N , K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
print(math.ceil((N-1)/(K-1)))

Solution (Python):
from math import ceil

n,k = map(int,input().split())

input()

if n == k:
    print(1)
else:
    print(ceil((n-1)/(k-1)))

Solution (Python):


from math import ceil

def solve(N, K):
    return ceil((N-1) / (K-1))

if __name__ == "__main__":

    N, K = [int(x) for x in input().split()]
    Ai = [int(x) for x in input().split()]
    print(solve(N, K))

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    while N > 1:
        N -= (K - 1)
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import math
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
c = math.ceil((n-1)/(k-1))

print(c)

Solution (Python):
M, N =map(int, input().split())
print(-(-(M-1)//(N-1)))

Solution (Python):
M, N =map(int, input().split())
A =list(map(int, input().split()))
print(-(-(M-1)//(N-1)))

Solution (Python):
import math

N, K = map(int, input().split())
A = list(map(int, input().split() ))
print(math.ceil( (N-1)/(K-1) ))

Solution (Python):
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
import math

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
print(math.ceil((n-1)/(k-1)))

Solution (Python):
N, K = map(int, input().split())
a = list(map(int, input().split()))

amin = min(a)

if len(a) == a.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - a.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)

Solution (Python):
N,K = map(int,input().split())
A = list(map(int,input().split()))

s = K
i = 1
while True:
    if s >= N:
        print(i)
        break
    i+=1
    s+=K - 1

Solution (Python):
n, k = map(int,input().split())
a = list(map(int,input().split()))

g=0
while n > k + (k - 1) * (g - 1):
    g += 1

print(g)

Solution (Python):
n, k = map(int, input().split())
a = list(map(int, input().split()))

print((n-2)//(k-1)+1)

Solution (Python):


import math

n, k = map(int, input().split())
nums = list(map(int, input().split()))
print(math.ceil((n - 1) / (k - 1)))

Solution (Python):
N, K = map(int, input().split())
A = list(map(int, input().split()))


import math


ans = math.ceil((N-K) / (K - 1)) + 1
print(ans)

Solution (Python):
import math

n,k = map(int,input().split())
input()
print(math.ceil((n-1)/float(k-1)))

Solution (Python):
import math
n,k=map(int,input().split())
input()
print(math.ceil((n-1)/float(k-1)))

Solution (Python):
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = math.ceil((n-1)/(k-1))
print(ans)

Solution (Python):
import math

n, k = [int(m) for m in input().split(" ")]
a = input()

print(math.ceil((n-1)/(k-1)))

Solution (Python):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))

num = ceil((N-1)/(K-1))

print(num)

Solution (Python):
l=list(map(int,input().split()))
n=l[0]
k=l[1]
ll=list(map(int,input().split()))

print((n+k-3)//(k-1))

Solution (Python):
import math

def C(n,k):
    result = math.ceil((n-1)/(k-1))
    print(result)

n,k = map(int, input().split())
a   = list(map(int,input().split()))
C(n,k)

Solution (Python):
n,k=map(int,input().split())
a=list(map(int,input().split()))
for g in range(1,n+1):
    if n<=g*(k-1)+1:
        print(g)
        exit()

Solution (Python):
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))

Solution (Python):
import numpy as np
import math


tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

N = N - K
cnt = 1
cnt += math.ceil(N / (K - 1))
print(cnt)

Solution (Python):

n, k = map(int, input().split())
a_tmp = input().split()
a = []
for _ in a_tmp:
    a.append(int(_))
g = 1
while n > (k + (k-1)*(g-1)):
    g += 1
print(g)

Solution (Python):
import math
header = [int(n) for n in input().split()]
dataLength = header[0]
subsetLength = header[1]
print(int(math.ceil((dataLength-1)/ (subsetLength-1))))

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)


def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))


def to_bin(x):
    return bin(x)[2:]



dp = None

def main():
    N, K = [int(_) for _ in input().split()]
    A = [int(_) for _ in input().split()]

    ans = 1
    idx = K - 1
    while idx < N - 1:
        ans += 1
        idx += (K - 1)

    print(ans)

    

    

    
    
    
    

    
    
    
    

    

main()

Solution (Python):


def main():
	N, K = map(int, input().split())
	lists = map(int, input().split())
	
	print(1-(-(N-K)//(K-1)))
	


if __name__ == '__main__':
	main()

Solution (Python):
import math
print((lambda x:math.ceil((int(x[0])-1)/(int(x[1])-1)))(input().split()))

Solution (Python):
import math
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
m = a.index(min(a))
print(math.ceil((len(a)-1)/(k-1)))

Solution (Python):
N, K = map(int, input().split())
l = [int(i) for i in input().split()]
if (len(l) - K) % (K - 1) == 0:
    print(int((len(l) - K) / (K - 1)) + 1)
else:
    print(int((len(l) - K) / (K - 1)) + 2)

Solution (Python):
from math import ceil

n, k = map(int, input().split())
A = list(map(int, input().split()))

index_min = A.index(1)
if not index_min % (k - 1) == 0:
    index_min = (index_min // (k - 1) + 1) * (k - 1)
index_min = min(index_min, n-1)

ans = ceil(index_min / (k - 1))
ans += ceil((n - index_min - 1) / (k - 1))

print(ans)

Solution (Python):


N,K = map(int,input().split())
li = list(map(int,input().split()))	
if N == K:
	print(1)
	quit()
i = 1
N = N-K

while N >= K:
	N = N - K +1
	i = i + 1

print(i+1)

Solution (Python):
n, k = input().split(" ")
n = int(n)
k = int(k)
a = input()
print(-(-(n - 1) // (k - 1)))

Solution (Python):
from math import ceil
n, k = map(int, input().split())
print(ceil((n-1)/(k-1)))

Solution (Python):
N, K = map(int, input().split(" "))
if (N-1) / (K-1) == int((N-1) / (K-1)):
  ans = int((N-1)/(K-1))
else:
  ans = int((N-1)/(K-1)) + 1
print(ans)

Solution (Python):
from math import ceil
N, K = list(map(int, input().split()))

A = input()  

r = ceil((N-1) / (K-1))
print(r)

Solution (Python):
from math import ceil
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

r = ceil((N-1) / (K-1))
print(r)

Solution (Python):
import math
n,k=map(int,input().split())
a=map(int,input().split())
print(math.ceil((n-1)/(k-1)))

Solution (Python):
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
print (N-1)/(K-1)+(0 if (N-1)%(K-1) == 0 else 1)

Solution (Python):

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

flag = 1
cnt = 0
while flag < n:
    flag += k - 1
    cnt += 1
print(cnt)

Solution (Python):
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(math.ceil((n-1)/(k-1)))

Solution (Python):


import math

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

print(math.ceil((n - 1) / (k - 1)))

Solution (Python):
import math
N = input().split()
K = int(N[1])
Z = int(N[0]) - K
print(math.ceil(Z / (K - 1))+ 1)

Solution (Python):
import sys

def main():
    N, K = map(int, raw_input().split(' '))
    A = map(int, raw_input().split(' '))

    position_1 = A.index(1)
    if position_1 <= K or N-K <= position_1:
        if (N-K) % (K-1) > 0:
            print 1 + (N-K)/(K-1) + 1
            return
        else:
            print 1 + (N-K)/(K-1)
            return

    minimum = sys.maxint
    for i in range(K):
        total = 1
        smaller_A = A[:position_1-K+1]
        bigger_A = A[position_1+i:]

        if len(smaller_A) % (K-1) == 0:
            total += len(smaller_A) / (K-1)
        else:
            total += (len(smaller_A) / (K-1)) + 1
        
        if len(bigger_A) % (K-1) == 0:
            total += len(bigger_A) / (K-1)
        else:
            total += (len(bigger_A) / (K-1)) + 1

        if total < minimum:
            minimum = total

    print total

main()

Solution (Python):
import math
(n,k) = input().split(" ")
n=int(n)
k=int(k)
arr = input().split(" ")

idx = arr.index("1")
if idx < k or n-idx-1 < k:
    num=math.ceil((n-k)/(k-1))+1
else:
    num1 = math.ceil((idx+1)/k)
    idx1=k+(k-1)*(num1-1)-1
    num = num1+math.ceil((n-idx1-k)/(k-1))+1
print(num)

Solution (Python):
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    m = min(A)
    mi = A.index(m)
    c = (N - 1) // (K - 1)
    if (N - 1) % (K - 1) > 0: c += 1
    print(c)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    m = min(A)
    mi = A.index(m)
    c = 0
    c += (N - 1) // (K - 1)
    if (N - 1) % (K - 1) > 0: c += 1
    print(c)

if __name__ == '__main__':
    main()

Solution (Python):


s = input()
splited = s.split(" ")

n = int(splited[0])
k = int(splited[1])

if k == 1:
	print ("1")
	exit()


a = 1 + (n-2)//(k-1)

print(a)

Solution (Python):
import sys
N,K = map(int,input().split())
A = list(map(int,input().split()))
place_one = A.index(1)

if (N-1)%(K-1)!=0:
    print((N-1)//(K-1)+1)
    sys.exit()
else:
    print((N-1)//(K-1))
    sys.exit()

Solution (Python):
import math
N, K = map(int, input().split())
input()
     
print(math.ceil((N-1)/(K-1)))

Solution (Python):
import math
N, K = map(int, input().split())
input()
     
print(math.ceil((N-1)/(K-1)))

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))
print((n - 1) // (m - 1) + ((n - 1) % (m - 1) != 0))

Solution (Python):
import math
N, K = map(int, input().split())
input()

print(math.ceil((N-1)/(K-1)))

Solution (Python):
import math
n, m = map(int, input().split())
s = map(int, input().split())
print(math.ceil((n-1)/(m-1)))

Solution (Python):
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))

Solution (Python):
import math

N,K=list(map(int,input().split(' ')))
A=list(map(int,input().split(' ')))

print(math.ceil((N-K)/(K-1))+1)

Solution (Python):
n, k = map(int, input().split())
A_len = len(list(map(int, input().split())))

i=0
while True:
    if n <= k:
        i+=1
        break
    i += n // k
    n = n // k + n % k

print(i)

Solution (Python):
nk=input().split()
l=input().split()

nk_i=[int(s) for s in nk]
N=nk_i[0]
K=nk_i[1]

l_i=[int(s) for s in l]

if N==K:
    print(1)
else:
    a=-(-(N-1)//(K-1))
    print(a)

Solution (Python):
N,K=list(map(int,input().split()))
print(-((1-N)//(K-1)))

Solution (Python):
import math

N,K = map(int, input().split())

ans = math.ceil((N-1) / (K-1))

print(ans)

Solution (Python):
NK = [int(i) for i in input().split()]
N, K = NK[0], NK[1]
A = input()
ans = (N - K) // (K - 1) + 1
if (N - K) % (K - 1) != 0:
    ans += 1

print(ans)

Solution (Python):
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N-1)/(K-1)))

Solution (Python):
def judge(all_num, cover_num):
    if ((all_num-1) % (cover_num-1)) == 0:
        return int((all_num-1)/(cover_num-1))
    else:
        return int((all_num-1)/(cover_num-1)) + 1


if __name__ == "__main__" :
    n_k = list(map(int, input().split()))
    array = list(map(int, input().split()))
    min_point = judge(n_k[0], n_k[1])
    print(min_point)

Solution (Python):
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
N,K=map(int,(input()).split(' '))
A=(input()).split(' ')

length=len(A)



print((length-1)//(K-1)+(0 if (length-1)%(K-1)==0  else 1 ))

Solution (Python):
import math

l = input().split()
n = l[0]
k = l[1]
l = input().split()



tmp = int(k)-1
x = math.ceil((int(n)-1)/tmp)


print(x)

Solution (Python):
n, k = [int(w) for w in input().split()]
a = [int(w) for w in input().split()]
t, i = 1, 0
while t < n:
    t += (k -1)
    i += 1
print(i)

Solution (Python):
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N - 1) / (K - 1)))

Solution (Python):
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

count = 1
rem = n-k
while(True):
    if(rem <= 0):
        break
    rem -= k-1
    count += 1
    
print(count)

Solution (Python):
N, K = map(int, raw_input().split(' '))

raw_input()


N = N - K
K = K - 1

print (N+K-1)/K + 1

Solution (Python):
N, K = [int(i) for i in input().split()]
number_list = [int(i) for i in input().split()]

count = 1
length = N - K
while length > 0:
    length -= K -1
    count += 1

print(count)

Solution (Python):
N,K=map(int, input().split())
A=input()
if (N-1)%(K-1):
    print((N-1)//(K-1)+1)
else:
    print((N-1)//(K-1))

Solution (Python):
import math
n, k = input().split()
n = int(n)
k = int(k)
aa = input().split()


 
if n==k:
   print(1)
else:
   print(math.ceil((n-1)/(k-1)))

Solution (Python):
import sys
import math
     
     
def main():
    """
    2 <= K <= N <= 10^5
    1 <= ai <= N
    1 <= i <= N
    """
    N, K = map(int, input().split())
    *A, = map(int, input().split())
 
    
    ans = editorial(N, K, A)
    print(ans)
     
     
def test_examples():
    nka_ans = [
        (4, 3, [2, 3, 1, 4], 2),
        (3, 3, [1, 2, 3], 1),
        (8, 3, [7, 3, 1, 8, 4, 6, 2, 5], 4),
    ]
 
    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans
     
     
def test_ans():
    nka_ans = [
        (5, 2, [1, 2, 3, 4, 5], 4),
        (5, 3, [1, 2, 3, 4, 5], 2),
        (5, 2, [5, 4, 3, 2, 1], 4),
        (5, 3, [5, 4, 3, 2, 1], 2),
    ]
     
    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans
     
     
def f_K(N, K, A):
    """
    最初に置く範囲は、 1_idx - K + 1 から 1_idx
    """
    idx = [i for i, a in enumerate(A) if a == 1][0]
    left_idx = max(0, idx - K)
    ans = float("inf")
    for i in range(left_idx, idx + 1):
        left = i
        right = max(0, N - left - K)
        tmp = (left + (K - 1) - 1) // (K - 1)
        tmp += 1
        tmp += (right + (K - 1) - 1) // (K - 1)
        ans = min(ans, tmp)
     
    return ans
     
     
def editorial(N, K, A):
    """
    端から端までカバーしていく
    K + (K - 1) * N (N >= 0)
    これは仮に１番左に1があったとき
    結果的には順番は気にしなくて良い
    上記でカバーしていくと、いつかは最初の1をカバーする
        カバーした順番を1をカバーしたことを最初に行えば変わらない
     
    TODO: editorial pdfの意味
        1 + g(K − 1) ≤ p ≤ 1 + (g + 1)(K − 1) なる整数 g
    """
    return ((N-1) + (K-1) - 1) // (K-1)
     
     
     
if __name__ == '__main__':
    main()

Solution (Python):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

I = A.index(1)

left = I
right = N - I - 1

left_q, left_r = divmod(left, K-1)
right_q, right_r = divmod(right, K-1)

res = math.ceil((left_r+right_r)/(K-1))
print(res + left_q + right_q)

Solution (Python):
import sys
import math


def main():
    """
    2 <= K <= N <= 10^5
    1 <= ai <= N
    1 <= i <= N
    """
    N, K = map(int, input().split())
    *A, = map(int, input().split())

    
    ans = editorial(N, K, A)
    print(ans)


def test_examples():
    nka_ans = [
        (4, 3, [2, 3, 1, 4], 2),
        (3, 3, [1, 2, 3], 1),
        (8, 3, [7, 3, 1, 8, 4, 6, 2, 5], 4),
    ]

    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans


def test_ans():
    nka_ans = [
        (5, 2, [1, 2, 3, 4, 5], 4),
        (5, 3, [1, 2, 3, 4, 5], 2),
        (5, 2, [5, 4, 3, 2, 1], 4),
        (5, 3, [5, 4, 3, 2, 1], 2),
    ]

    for N, K, A, ans in nka_ans:
        assert editorial(N, K, A) == ans
        assert f_K(N, K, A) == ans


def f_K(N, K, A):
    """
    最初に置く範囲は、 1_idx - K + 1 から 1_idx
    """
    idx = [i for i, a in enumerate(A) if a == 1][0]
    left_idx = max(0, idx - K)
    ans = float("inf")
    for i in range(left_idx, idx + 1):
        left = i
        right = max(0, N - left - K)
        tmp = (left + (K - 1) - 1) // (K - 1)
        tmp += 1
        tmp += (right + (K - 1) - 1) // (K - 1)
        ans = min(ans, tmp)

    return ans


def editorial(N, K, A):
    """
    端から端までカバーしていく
        K + (K - 1) * N (N >= 0)
        これは仮に１番左に1があったとき
    結果的には順番は気にしなくて良い
    上記でカバーしていくと、いつかは最初の1をカバーする
        カバーした順番を1をカバーしたことを最初に行えば変わらない

    TODO: editorial pdfの意味
        1 + g(K − 1) ≤ p ≤ 1 + (g + 1)(K − 1) なる整数 g
    """
    return ((N-1) + (K-1) - 1) // (K-1)



if __name__ == '__main__':
    main()