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):
import numpy as np
import math

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

A_np = np.array(A)

argmin = A_np.argmin() + 1

left = (math.ceil((argmin - K) / (K - 1)) + 1)
left = max(0, left)

already = (left - 1) * (K - 1) + K if left != 0 else 1

nokori = (N - already + 1)

right = (math.ceil((nokori - K) / (K - 1)) + 1)

print(right + left)

Solution (Python):


import math

def main():
    n, k = map(int, input().split())
    an = list(map(int, input().split()))
    assert len(an) == n
    mi = min(an)
    imin = []
    for i in range(n):
        if an[i] == mi:
            imin.append(i)

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

main()

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

l = 1
ans = 0

while l < n:
    ans += 1
    l += k-1

print(ans)

Solution (Python):
from math import ceil

N, K = map(int, input().split())
As = 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()))

b = min(a)

lft = 0
rgt = 0
for i in range(len(a)):
    if a[i] == b:
        lft = i
        break

ret = 0
i = 0
for i in range(len(a)):
    if a[i] == b:
        continue
    flag = False
    for j in range(k - 1):
        if not i + j < n:
            break
        if a[i+j] == b:
            flag = True
        a[i+j] = b
    if flag and i+k-1 < len(a):
        a[i+k-1] = b
    ret += 1

print(ret)

Solution (Python):


def main():
	n, k = list(map(int, input().split()))

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

if __name__ == '__main__':
	main()

Solution (Python):


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

a = map(int,raw_input().split())













ans = (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()))
for i in range(1, 100000):
    if N <= K + max(0, (K - 1) * (i - 1)):
        print(i)
        break

Solution (Python):
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('a1.in')


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n, k = read_int_list()
    a = read_int_list()
    res = 1
    for i in range(k - 1, n - 1, k - 1):
        res += 1
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
N, K = map(int, sys.stdin.readline().split())
rhs = N - K
ans = rhs // (K - 1) + 1
while (K - 1) * (ans - 1) < rhs:
    ans += 1
print(ans)

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

for i, j in enumerate(a):
    if(j == 1): break

count = 0
tmp = i
while(i > 0):
    count += 1
    i -= (k - 1)

i = tmp - i
while(i < n - 1):
    count += 1
    i += (k - 1)

print(count)

Solution (Python):
from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque


def read():
    return int(input())


def readmap():
    return map(int, input().split())


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


N, K = readmap()
A = readlist()
ind1 = A.index(1)

ans = 100000
for k in range(max(0, ind1 - K + 1), ind1 + 1):
    left = int(math.ceil(k / (K - 1)))
    right = max(0, int(math.ceil((N - k - K) / (K - 1))))
    ans = min(ans, left + right + 1)

print(ans)

Solution (Python):
import math

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

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

print(ans)

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

count = 0
now = 0
while now < n-1:
	now += k-1
	count += 1
	if now == s and (now+k) > n-1:
		now += k-2
		count += 1
print(count)

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

ans = (N-1)//(K-1)

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

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

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

Solution (Python):
read = lambda: map(int, input().split())
n, k = read()
a = list(read())
x = a.index(1)
ans = (n - 2) // (k - 1) + 1
print(ans)

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

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

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

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

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

cnt = 0
cnt += (min_i+ k-2) // (k - 1)
i = max(min_i + 1, (min_i+ k-2) // (k - 1) * (k - 1) + 1)
while i < n:
    while a[i] == min_v:
        i += 1
        if i >= n:
            break
    if i >= n:
        break
    cnt += 1
    i += (k - 1)

print(cnt)

Solution (Python):
N,K=map(int,input().split())
a = input()
ans = (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):
    ans =(N-1)//(K-1)+1
else:
    ans = (N-1) // (K - 1)


print(ans)

Solution (Python):

import math

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

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

print(ans)

Solution (Python):
from sys import stdin, stdout

n, k = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))
ind = values.index(1)

left, right = ind, n - 1 - ind
ans = (left + right + k - 2) // (k - 1)
stdout.write(str(ans))

Solution (Python):
N, K = map(int, input().split())
a = len(input().split())
func = lambda x: int(x) if x == int(x) else int(x) + 1
print(func((a - 1) / (K - 1)))

Solution (Python):
INF = 10 ** 20

n, k = map(int, input().split())
alst = list(map(int, input().split()))
init_ind = alst.index(1)
left = init_ind
right = n - init_ind - 1

ans = INF
for l in range(k):
  r = k - l - 1
  if l <= init_ind and init_ind + r <= n - 1:
    left2 = left - l
    right2 = right - r
    ans = min(ans, 1 + left2 // (k - 1) + bool(left2 % (k - 1)) + right2 // (k - 1) + bool(right2 % (k - 1)))
print(ans)

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

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

cnt=0
for i in range(k,n+1,k-1):
    cnt+=1
else:
    if i<n:
        cnt+=1
print(cnt)

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

import math

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

Solution (Python):
read = lambda: map(int, input().split())
n, k = read()
a = list(read())
x = a.index(1)
ans = (n - 2) // (k - 1) + 1
print(ans)

Solution (Python):
import math


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

Solution (Python):
import math

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

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

print(ans)

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

Solution (Python):


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

z=0
for i, ai in enumerate(a):

    if ai == 0:
        z=i
        break


        
p=(n-1+k-1-1)//(k-1)

print(p)

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 math
n, k = 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 = list(map(int,input().split()))
N2 = N-K
d = K-1
print((N2-1)//d +2)

Solution (Python):


N, K = map(int, input().split())
_ = 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()))
print(math.ceil((N-1) / (K-1)))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    if n == k:
        return 1
    a = LI()
    r = (n - k + k - 2) // (k-1) + 1

    return r


print(main())

Solution (Python):




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


if __name__ == '__main__':
    main()

Solution (Python):
n,k = map(int,input().split())
l = [int(x) for x in input().split()]

ans = 1 
n-=k 
while n>0:
    n-=(k-1)
    ans+=1 
print(ans)

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):
N, K = map(int, input().split())
_ = input()

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

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

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

Solution (Python):

import sys

input=sys.stdin.readline

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

vals=1
ans=0
while vals<n:
    vals+=k-1
    ans+=1
print(ans)