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



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
i = 1
ans = 0
flag = False
while True:
    try:
        if(A == []):
            if(flag == False):
                print(ans)
            break
        if(ans == 0):
            for i in range(K):
                A.pop(0)
        else:
            for i in range(K-1):
                A.pop(0)
        ans += 1
    except:
        print(ans+1)
        flag = True

Submission status: Accepted

Solution code:
N, K = [int(c) for c in input().split()]
As = [int(c) for c in input().split()]
t = 1 if (N - 1) % (K - 1) else 0
print((N - 1) // (K - 1) + t)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
input()
if N == K:
    print(1)
elif K == 2:
    print(N - 1)
else:
    tmp = (N - 1) // (K - 1)
    if (N - 1) % (K - 1) != 0:
        tmp += 1
    print(tmp)

Submission status: Accepted

Solution code:
n , k = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
if k == n:
    print(ans)
else:
    for _ in range(k + 1,n + 1,k-1):
        ans += 1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
#print(A)
ans=0
i=0
while(i<len(A)-1):
    ar=[]
    try:
        ar=A[i:i+k]
    except:
        ar=A[i:len(A)]
    i=i+k-1
    ans=ans+1
print(ans)

Submission status: Accepted

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

def num(x,K):
    return(math.ceil(x/(K-1)))
    
left = A.index(1)
right = N-1-A.index(1)

left_noba = left % (K-1)
left_num = left // (K-1) + 1

right_noba = K - 1 - left_noba

if right >= right_noba:
    right_num = num(right - right_noba,K)
else:
    right_num = 0
    
print(left_num + right_num)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
count = 1
increment = K -1
while K < N:
    K = K + increment
    count += 1

print(count)

Submission status: Accepted

Solution code:
import sys
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n,k = na()
a = na()

if n == k:
    print(1)
elif k >= n//2:
    print(2)
elif k == 2:
    print(n-1)
else:
    print(math.ceil((n-k)/(k-1))+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
A_b = [0] * N

if N == K:
    print(1)
else:
    n = 1
    N -= K
    while N > 0:
        N -= (K - 1)
        n += 1
    print(n)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

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

max_idx = a.index(min(a))

left = a.index(min(a))
right = n - left - 1

res = 0

left_mod = left % (k - 1)
res += left // (k - 1)

right_mod = right % (k - 1)
res += right // (k - 1)

if left_mod == 0 and right_mod == 0:
    res += 0
elif k >= left_mod + right_mod + 1:
    res += 1
else:
    res += 2

print(res)

Submission status: Accepted

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

#print(N, K)
#print(A)
if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    a = N // (K-1)
    if N - a*(K-1) >= 2:
        print(a+1)
    else:
        print(a)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A_arr = list(map(int, input().split()))

idx = A_arr.index(1)
leftn = idx
rightn = N - idx - 1

c = []

for i in range(max(K - leftn - 1, 0), K):
    c.append(1 + ((leftn - (K-1-i)) + K-1-1) // (K-1) + ((rightn - i) + K-1-1) // (K-1))

print(min(c))

Submission status: Accepted

Solution code:
N, K =map(int,input().split())
N-=K
count=1
while N>0:
    N-=K-1
    count+=1
print (count)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
x = a.index(1)
r = (x+k-2)//(k-1)
x = r*(k-1)
r += (n-x+k-3)//(k-1)
print(r)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest


# See:
# http://terukizm.hatenablog.com/entry/20120505/1336218368
def ceil(src, range):
    return ((int)(src / range) + 1) * range


if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    tmp = (n - 1) % (k - 1)

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

Submission status: Accepted

Solution code:
nk=input().split()
n=int(nk[0])
k=int(nk[1])
if (n-1)%(k-1)==0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

one_pos = 0
for i, num in enumerate(a):
    if num == 1:
        one_pos = i
        break
count = (i - 1) // (K - 1) + 1
if count * (K - 1) >= len(a):
    pass
else:
    if count * (K - 1) + 1 > i + 1:
        count += (len(a) - (count * (K - 1) + 1) - 1) // (K - 1) + 1
    else:
        count += (len(a) - (i + 1) - 1) // (K - 1) + 1
print(count)

Submission status: Accepted

Solution code:
#coding:utf-8
N, K = map(int,input().split())
nums = list(input().split())

for i in range(N):
    if nums[i] == "1":
        index = i

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

    after = N - (total * (K-1) + 1)

    if after % (K-1) == 0:
        total += after // (K-1)
    else:
        total += after // (K-1) + 1

    print(total)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    if A[i] == 1:
        x = i
        break

y = N - x - 1
ans = float("inf")


def ceil(m, n):
    return -(-m // n)


for s in range(K):
    t = K - 1 - s
    ans = min(ans, ceil(y - t, K - 1) + ceil(x - s, K - 1))

print(ans + 1)

Submission status: Accepted

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

if n == k :
    print(1)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
idx=A.index(1)
cnt=0
if idx:
    if idx+1<=K:
        cnt=1
        A[:K]=[1]*K
    else:
        cnt=(idx-1)//(K-1)+1
        num=cnt*(K-1)+1
        A[:num]=[1]*num
A=A[::-1]
idx=A.index(1)
if idx:
    if idx+1<=K:
        cnt+=1
        A[:K]=[1]*K
    else:
        cnt+=(idx-1)//(K-1)+1
        num=cnt*(K-1)+1
        A[:num]=[1]*num
print(cnt)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i, v in enumerate(a):
    if v == 1:
        ind1 = i
        break

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
n-=k
ans=1

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

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = input()
g = n - k
if k > n :
    print(0)
else:
    t = 1
    while  0 < g :
        g = g - (k-1)
        t += 1
print(t)

Submission status: Accepted

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

if(N==K):
    print("1")
elif(K>=(N/2)):
    print("2")
elif(3<=K and K<(N/2)):
    print((N-(K+1))//(K-1)+2)
else:
    print(N-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
cnt = 0
ans = 1
while True:
    ans += k-1
    cnt += 1
    if ans >= n:
        break
print(cnt)

Submission status: Accepted

Solution code:
N, K = [int(w) for w in input().split()]
A    = [int(w) for w in input().split()]
if len(A) != N: raise

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

for i in range(1, N):

    if (K - 1) * i + 1 >= N:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
N, K = map(int, input().split())
an = list(map(int, input().split()))

tN = N - K

ans = -(-tN // (K-1)) + 1
print(ans)

Submission status: Accepted

Solution code:
# your code goes here

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

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

for i in range(N):
	if A[i] == 1:
		place_one = i
		break

ans_left = (place_one+(K-2))//(K-1)
# print(ans_left)
ans_left += (N-(K-1)*ans_left+(K-3))//(K-1)
# print(ans_left)

ans_right = (N-1-place_one+(K-2))//(K-1)
# print(ans_right)
ans_right += (N-1-(K-1)*ans_right+(K-2))//(K-1)
# print(ans_right)

print(min(ans_left,ans_right))

Submission status: Accepted

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

if k == 2:
    print(n-1)

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

Submission status: Accepted

Solution code:
import math

x,y = map(int,input().split())
input()

low = math.floor(x / (y - 1))
high = math.ceil(x / (y - 1))

if low == high:
    low = low - 1

if ((y - 1) * low) + 1 >= x:
    print(low)
else:
    print(low + 1)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
def main():
    
    #input
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    
    #judge
    if (N-1)%(K-1) == 0:
        ans = (N-1)//(K-1)
    else:
        ans = (N-1)//(K-1) + 1
        
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

(n, k) = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
one = arr.index(1)
if k == n:
    print(1)
else:
    res1 = math.ceil(one / (k - 1))
    one1 = (k - 1) * res1
    res1 += math.ceil((len(arr) - one1 - 1) / (k - 1))

    arr.reverse()
    res2 = math.ceil(one / (k - 1))
    one2 = (k - 1) * res2
    res2 += math.ceil((len(arr) - one2 - 1) / (k - 1))
    print(min(res1, res2))

Submission status: Accepted

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

import numpy as np
a = np.array(a)
a1 = np.where(a == 1)[0][0]
ar = len(a) - a1 - 1
al = a1

if ar > al:
    while True:
        if ar % (k-1) == 0 or al % (k-1) == 0:
            break            
        ar -= 1
        al += 1

if ar <= al:
    while True:
        if ar % (k-1) == 0 or al % (k-1) == 0:
            break            
        ar += 1
        al -= 1


nr = int(np.ceil(ar / (k-1)))
nl = int(np.ceil(al / (k-1)))

ans = nr + nl

print(ans)

Submission status: Accepted

Solution code:
N, K = list(map(int,input().strip().split(' ')))
A = list(map(int,input().strip().split(' ')))
tmp = N-K
ans = 1
flg = 0
while tmp >= 0:
    if tmp == 0:
        print(ans)
        flg = 1
        break
    tmp = tmp - (K-1)
    ans = ans + 1

if flg ==0:
    print(ans)

Submission status: Accepted

Solution code:
import sys
import math
if __name__ == "__main__":
    N, K = list(map(int, (input().split(' '))))
    A = list(map(int, (input().split(' '))))
    min = math.ceil(((N - 2) + 1) / (K - 1))
    print(min)

Submission status: Accepted

Solution code:
from math import ceil

if __name__ == '__main__':
    n, k = map(int, input().split())
    a_str = input().split()
    a = []
    a_min = n + 1
    a_min_index = 0
    for i, a_i_str in enumerate(a_str):
        a_i = int(a_i_str)
        if a_i < a_min:
            a_min = a_i
            a_min_index = i

    n_left_elements = a_min_index
    left_count = ceil(n_left_elements / (k - 1))

    right_index_start = left_count * (k - 1)
    right_count = ceil((n - right_index_start - 1) / (k - 1))

    ans = left_count + right_count
    print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import math

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

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

minNum = min(a)

li = len([i for i in range(len(a)) if minNum == a[i]])


print(math.ceil((len(a)-li)/(k-1)))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    _ = list(map(int, input().split()))
    r, m = divmod(n - 1, k - 1)

    if m == 0:
        print(r)
    else:
        print(r + 1)

main()

Submission status: Accepted

Solution code:
# coding: utf-8

n, k = [int(x) for x in input().split()]
aa = [int(x) for x in input().split()]

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = map(int,input().split())
ans = 1
num = k
while num < n:
    num += (k - 1)
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = -(-(n - 1) // (k-1))
print(ans)

Submission status: Accepted

Solution code:
N, K = input().split(' ')
N, K = int(N), int(K)
A = [int(Ai) for Ai in input().split(' ')]

n = 1
for i in range(N):
    n += K-1
    if n >= N:
        print(i+1)
        break

Submission status: Accepted

Solution code:
# import platform
# ver = platform.python_version_tuple()
# if int(ver[1]) < 5:
#     from fractions import gcd
# else:
#     from math import gcd

# from itertools import accumulate, combinations, permutations, product
# from bisect import bisect, bisect_left
# from collections import Counter, defaultdict, deque
# from heapq import heappush, heappop

# from functools import lru_cache
# @lru_cache(maxsize=1024)

from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

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

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

main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
import math as m
if n==k:
    print(1)
else:
    print(1+m.ceil((n-k)/(k-1)))

Submission status: Accepted

Solution code:
N,K=(int(i) for i in input().split(" "))
A=input()
print(1-((K-N)//(K-1)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
n = 0
while 1:
    if K + (K-1) * n >= N:
        break
    n += 1
print(n + 1)

Submission status: Accepted

Solution code:
import math

if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    As = list(map(int, input().split()))
    
    if N <= K:
        print("1")
        exit()
    n = math.ceil((N - K)/(K - 1))
    print(n + 1)

Submission status: Accepted

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

a = (N-2)//(K-1)+1

print(a)

Submission status: Accepted

Solution code:
NK=input()
NK=NK.rstrip().split(" ")
N=int(NK[0])
K=int(NK[1])

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

Submission status: Accepted

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

a = list(map(int, input().split()))
count = 0
m = -1
for i in range(n):
    if a[i] == 1:
        m = i
        break

if k >= m+1:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1
elif k >= n - m:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1
else:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8
#

def main(n, k, a):
    t_n = n
    t_k = k
    t_a = a
    counter = 0
    while t_n > 0:
        if counter == 0:
            t_n -= t_k
        else:
            t_n -= (t_k - 1)
        counter += 1
    print(counter)


if __name__ == '__main__':
    try:
        n, k = list(map(float,input().strip().split(' ')))
        a = list(map(int,input().strip().split(' ')))
        main(n,k,a)
    except EOFError:
        pass

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

Solution code:
from math import ceil
N, K = [int(c) for c in raw_input().split()]
A = [int(c) for c in raw_input().split()]

print int(ceil((N-1.0)/(K-1.0)))

Submission status: Accepted

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

counter = 1
while (True):
    if counter*(K-1) + 2 > N:
        break
    else:
        counter += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
nums = list(map(int,input().split()))

for i in range(1,N):
  if N <= i*K-i+1:
    print(i)
    break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
a, b = map(int,input().split())
A = list(map(int,input().split()))
ans = math.ceil((a-1)/(b-1))
print(int(ans))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c=0
while a>1 :
    a-=b
    c+=1
    a+=1
print(c)

Submission status: Accepted

Solution code:
def main():
    def ceil(x):
        if x % 1 == 0:
            return int(x)
        return int(x + 1)
    N, K = list(map(int, input().split()))
    lul = input()
    print(1 + ceil((N - K) / (K - 1)))
    return 0
main()

Submission status: Accepted

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

lgt = n
if n==k: print(1)
else:
    lgt-=k
    ans=1
    while 1:
        lgt-=k-1
        ans+=1
        if lgt<=0:
            break
    print(ans)

Submission status: Accepted

Solution code:
n, k = list(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))

Submission status: Accepted

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

n = len(a)
idx = 1
cnt = 0
while idx < n:
    idx += k-1
    cnt += 1
print(cnt)

Submission status: Accepted

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

if N == K:
    print(1)
    exit()
index = A.index(1)
left = index
right = N - index - 1
count = 0
tmp = left % (K-1)
count += (left//(K-1)) + (tmp > 0)
if tmp > 0:
    right -= K - 1 - tmp 
count += (right//(K-1)) + (right%(K-1) > 0)

print(count)

Submission status: Accepted

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

pos1 = A.index(1)
before1 = pos1
after1 = N-pos1-1

ans = 0
if(before1%(K-1)==0):
    ans += before1//(K-1)
else:
    ans += before1//(K-1)+1
    after1 -= (K-1)-before1%(K-1)

if(after1%(K-1)==0):
    ans += after1//(K-1)
else:
    ans += after1//(K-1)+1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
s = 0
for i in a:
    if a == 1:
        s = i
        break
t,u = divmod(n-1,k-1)
if u != 0:
    t += 1
print(t)

Submission status: Accepted

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

from math import ceil
print(ceil((N-1)/(K-1)))

Submission status: Accepted

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

a, b = divmod(n-1, k-1)
print( a + (b != 0))

Submission status: Accepted

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

for i in range(n):
    if n <= i*(k-1)+1:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
A = list(map(int, input().split()))
print((n-2)//(k-1)+1)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
if (a-1)%(b-1)==0:
  ans=(a-1)//(b-1)
else:
  ans=ans=(a-1)//(b-1)+1
print(ans)

Submission status: Accepted

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

c = 1
rem = len(A) - K
while True:
  if rem > K - 1:
    c += 1
    rem -= K - 1
  else:
    break
if rem == 0:
  print(c)
else:
  print(c + 1)

Submission status: Accepted

Solution code:
N,K=map(int, raw_input().split())
A=map(int, raw_input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math 

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

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

Submission status: Accepted

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
index1 = 0
for i in range(n):
    if a[i] == 1:
        index1 = i
print(math.ceil(i/(k-1))+math.ceil((n-i-1)/(k-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
As = list(map(int, input().split()))


def calc(n, k, As):
    from math import ceil
    if k >= n:
        return 1
    return ceil((n - 1) / (k - 1))


print(calc(N, K, As))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(" "))
A = map(int, input().split(" "))

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

pos = 0
count = 0
while pos < N:
    if pos == 0:
        pos += K
    else:
        pos += K - 1
    count += 1

print(count)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A=[int(i) for i in input().split()]
ans = 1
N -= K
while N > 0:
    N += 1
    N -= K
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp
import itertools
import functools
import math

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N,K = ria()
if N<=K:
  print(1)
else:
  print(math.ceil((N-K)/(K-1))+1)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
aa = map(int, input().split())
# n == len(aa)

c = 0
n = n - k
if n <= 0:
    print(1)
    exit()
k = k - 1
print(1 + (n + k - 1) // k)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 1
x = K
while x < N:
    x += K - 1
    ans += 1
    if x >= N:
        break
print(ans)

Submission status: Accepted

Solution code:
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
import math 
# import collections
# import string
# ===================================
n, k = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
ans = -1
if n <= k:
	ans = 1
else:
	ans = 1 + math.ceil((n-k)/(k-1))
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
c = 1
s = N-K
while(s>0):
  c += 1
  s -= K-1
print c

Submission status: Accepted

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

Submission status: Accepted

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

a = list(map(int,input().split()))
cnt = 1

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

print(cnt)

Submission status: Accepted

Solution code:
import math

a,b = map(int, input().split())
kazu = input().split()
iti = 0
for i in range(a):
    if kazu[i] == "1":
        iti = i
        break
# print(a,b,iti)

print(math.ceil((a-1)/(b-1)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
input()
n -= k
ans = 1
while n > 0:
  n -= (k - 1)
  ans += 1

print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
def abc101_c():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = (n - 1) // (k - 1) + [1, 0][(n - 1) % (k - 1) == 0]
    return ans


print(abc101_c())

Submission status: Accepted

Solution code:
N,K=list(map(int, input().strip().split()))
A=list(map(int, input().strip().split()))
c=N
c-=K
ct=1
while c>0:
    ct+=1
    c-=K-1
print(ct)

Submission status: Accepted

Solution code:
import math

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

n = n - k
cnt = 1

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

Submission status: Runtime Error

Solution code:
8 2
7 3 1 8 4 6 2 5

Submission status: Runtime Error

Solution code:
n,k=int(input().split());print(0--~-n//~-k)

Submission status: Runtime Error

Solution code:
n,k=map(int,open(0).split())
print(0--~-n//~-k)

Submission status: Runtime Error

Solution code:
a,b=int(input())
for x in input().split():
  print(x)

Submission status: Runtime Error

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

min_a = str(min(a))
min_loc = int(map(str, a).rfind(min_a))
if (min_loc - 1) % (k - 1) == 0:
  print(round((min_loc - 1 ) / (k - 1)) + round((n - min_loc) / (k - 1) ))
else:
  print(round((min_loc - 1 ) / (k - 1) + 1) + round((n - min_loc) / (k - 1) + 1))

Submission status: Runtime Error

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

min_loc = int(map(str, a).rfind("min(a)"))
if (min_loc - 1) % (k - 1) == 0:
  print(round((min_loc - 1 ) / (k - 1)) + round((n - min_loc) / (k - 1) ))
else:
  print(round((min_loc - 1 ) / (k - 1) + 1) + round((n - min_loc) / (k - 1) + 1))

Submission status: Runtime Error

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

min_loc = map(str, a).rfind(min(a))
if (min_loc - 1) % (k - 1) == 0:
  print(round((min_loc - 1 ) / (k - 1)) + round((n - min_loc) / (k - 1) ))
else:
  print(round((min_loc - 1 ) / (k - 1) + 1) + round((n - min_loc) / (k - 1) + 1))

Submission status: Runtime Error

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

min_loc = map(str, a).rfind(min(a))
if (min_loc - 1) % (k - 1) == 0:
  print(round((min_loc - 1 ) / (k - 1)) + round((n - min_loc) / (k - 1) ))
else:
  print(round((min_loc - 1 ) / (k - 1) + 1) + round((n - min_loc) / (k - 1) + 1))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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