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:
#!/usr/bin/env python3

import sys
import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    L = lmi()
    L.sort()
    minimum = L[0]
    cnt = 0
    for i in range(n):
        if L[i] == minimum:
            cnt += 1
    print(math.ceil((n - cnt) / (k - 1)))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
i = 1
while  n > k + (k-1)*(i-1):
    i += 1

print(i)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
print(1 if n <= k else 1 + -(-(n - k) // (k - 1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc101


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

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


print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_min = min(A)
index = A.index(A_min)
ans = 0
left = index
right = N - 1 - index
if left % (K - 1) != 0:
    right -= K - 1 - left % (K - 1)
elif right % (K - 1) != 0:
    left -= K - 1 - right % (K - 1)
ans += math.ceil(left / (K - 1))
ans += math.ceil(right / (K - 1))   
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(float, input().split())
ans = -(-(n-1) // (k-1))
print(int(ans))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
print(0--~-n//~-k)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,K=map(int,readline().split())
    a=list(map(int,readline().split()))

    m=N-1
    l=K-1
    print((m+l-1)//l)
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 1
n -= k
k -= 1

if n % k == 0:
    ans += n // k
else:
    ans += n // k + 1

print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

def solve(N,K,A):
    ans = -(-(N-1)//(K-1))
    return ans
print(solve(N,K,A))

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
import sys
import math

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

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

Submission status: Accepted

Solution code:
import math

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

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

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=1
n=n-k
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()))


min_a = A.index(min(A))

left = min_a
right = n - min_a - 1


min_ = min(left, right)
max_ = max(left, right)


t = 0
min_ = min_ - k
t +=1
temp = 0
if min_ > 0:
    if min_ % (k - 1) != 0:
        temp = min_ // (k - 1)
    else:
        temp = min_ // (k - 1) + 1
    min_ -= temp * (k - 1)
t += temp

max_ = max_ + min_ + 1

if max_ % (k - 1) == 0:
    t += max_ // (k - 1)
else:
    t += max_ // (k - 1) + 1

print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x, y = map(int,input().split())
li = list(map(int,input().split()))

if (x-1)%(y-1) == 0:
    print((x-1)//(y-1))
else:
    print((x-1)//(y-1)+1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, A: "List[int]"):
    m = min(A)
    m1 = A.index(m)
    ans = -(-m1 // (K - 1))
    c = ans * (K - 1) + 1
    while c < N:
        while A[c] == m:
            c += 1
        c += K - 1
        ans += 1
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int, input().split())
print(-(-(n-1)//(k-1)))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
import math

def main():
    N, K = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    print(math.ceil((N-1)/(K-1)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

q = (n-1) // (k-1)
r = (n-1) % (k-1)

if r: print(q+1)
else: print(q)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0,n,k-1):
  min_n = min(A[i:i+k])
  max_n = max(A[i:i+k])
  if min_n != max_n:
    counter += 1
  if i+k-1 < n:
    A[i+k-1] = min_n
  
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
for i in range(1, N):
    if A[i] != A[0]:
        idx = i
        break
# int((N - idx) / K)
if (N - idx) % (K - 1) == 0:
    print(int((N - idx) / (K - 1)))
else:
    print(int((N - idx) / (K - 1)) + 1)

Submission status: Accepted

Solution code:
n,k=list(map(int, input().split()))
a= list(map(int, input().split()))
final=min(a)
ans=0
flag=-1
check=0
for v in a:
    if flag==-1 and v!=final:
        flag=2
        ans+=1
        check=0
        if flag==k:
            flag=-1
    elif flag>=0:
        if check==0 and v==final:
            flag-=1
            check=1
        flag+=1
        if flag==k:
            flag=-1
print(ans)

Submission status: Accepted

Solution code:
import math

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

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# solution

nim,mike=map(int,input().split())

array=[int(x) for x in input().split()]

print((nim+mike-3)//(mike-1))

Submission status: Accepted

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

idx = As.index(min(As))
left = idx

n_l = (left + k - 2) // (k - 1)

right = n - ((n_l) * (k-1)) - 1

n_r = (right + k - 2) // (k - 1)

print(n_l + n_r)

Submission status: Accepted

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

Submission status: Accepted

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

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

    answer = 0
    for i in range(N):
        if K + (i-1)*(K-1) >= N:
            answer = i
            break

    print(answer)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()

K -= 1
i = A.index(1)

# 怒りの全探索
ans = 0
for j in range(0, N - 1, K):
    ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
import math
total = 0
N,M = list(map(int,input().split()))
M = M-1
n_l = "".join(input().split())
A = n_l.find("1")
before = A
after = N-A-1
while before > 0:
    before-=M
    total +=1
if before < 0:
    before = abs(before)
    after -= before
while after > 0:
    after-=M
    total +=1
print(total)

Submission status: Accepted

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

g = 1

while N > K + (K - 1) * (g - 1):
    g += 1
print(g)

Submission status: Accepted

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

cnt = 1
length = K
while True:
    if length >= N:
        print(cnt)
        break
    length += K-1 
    cnt += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n, k = nm()
a = nl()

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

Submission status: Accepted

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

min_num=min(A)
count=A.count(min_num)
target=len(A)-count
K_num=K-1

print(int(-(-target//K_num)))

Submission status: Accepted

Solution code:
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    print((n + k - 3) // (k - 1))

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    A = readInts()
    import math
    nokori = n - k
    #print(nokori)
    cnt = 1
    cnt += math.ceil(nokori/(k-1))
    print(cnt)




if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input().rstrip().split()
preans=(int(n[0])-1)/(int(n[1])-1)
 
ans=int(preans)
if (int(n[0])-1)%(int(n[1])-1)!=0:
  ans+=1
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
print((len(A)-1)//(K-1) + int(bool((len(A)-1)%(K-1))))

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))
no = list(map(int, input().split()))

zan = NK[0]
counter = 0
while(NK[1] < zan):
    zan -= NK[1] - 1
    counter += 1

print(counter + 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import statistics
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
  print(ceil((N-1)/(K-1)))
  
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)




def solve():
    N, K = iip(False)
    A = iip(False)

    if N == 1:
        return 0
    if N <= K:
        return 1

    return -(-(N-1) // (K-1))


#####################################################ライブラリ集ここから

def iip(listed=True, num_only=True):  # 数字のinputをlistで受け取る
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): # 関数を二分探索
    l = left
    r = right
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)




def solve():
    N, K = iip(False)
    A = iip(False)

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


#####################################################ライブラリ集ここから

def iip(listed=True, num_only=True):  # 数字のinputをlistで受け取る
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): # 関数を二分探索
    l = left
    r = right
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 1
n = n-k

while True:
    if n<=0:
        print(ans)
        exit()
    n = n-k+1
    ans += 1

Submission status: Accepted

Solution code:
import sys

def resolve():
    N, K = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    res = 0
    covered = 0
    while True:
        if covered >= N:
            break
        if res == 0:
            covered = K
        else:
            covered += K - 1
        res += 1
    print(res)

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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