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:
from math import ceil

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

Submission status: Accepted

Solution code:
import itertools
import math
import sys

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

print(math.ceil((n - k) / (k - 1)) + 1)
# ix = al.index(1)
# print(ix)
# cnt = 0
# if k >= ixx or k >= (n - ixx):
#     x = k
#     cnt += 1
#     while (x < n):
#         x += k
#         cnt += 1

# else:

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import math

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

min_index = A.index(min(A))

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
resolve()

Submission status: Accepted

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

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

idx = a.index(1)

left = idx
right = n - (idx + 1)

ans = 10 ** 10

for i in range(k):
    cnt = 1
    left_ = left - i
    right_ = right - (k - 1 - i)
    cnt += left_//(k - 1) + right_//(k - 1) + int(not left_ % (k - 1) == 0) + int(not right_ % (k - 1) == 0)
    ans = min(ans, cnt)

print(ans)

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:
def main():
    N, K = (int(i) for i in input().split())
    _ = [int(i) for i in input().split()]
    print(0--(N-1)//(K-1))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
now = k
cnt = 1
while now < n:
    now += (k-1)
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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

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

ans = 10**18

for i in range(N-K+1):
    if i<=mark<=i+K-1:
        ans = min(ans, 1+(i+K-1-1)//(K-1)+(N-i-K+K-1-1)//(K-1))

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
temp = 0
i = 0
while True:
    if i == 0:
        temp += k
    else:
        temp += k-1
    if temp >= n:
        print(i+1)
        exit()
    i += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    n=1
    for i in range(N):
        if n>=N:
            break
        n+=K-1
    print(i)
#%%submit!
resolve()

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 math
n, k=map(int, input().split())
a=list(map(int, input().split()))

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

#数列の最小値は１であり、一回の操作で最大k-1個を増やすことができる
ans=(n-1)//(k-1)+min(1,(n-1)%(k-1))
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import math
def resolve():
    N,M=pin()
    print(math.ceil((N-1)/(M-1)))

#%%submit!
resolve()

Submission status: Accepted

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

ans = 1
tmp = k

while True:
  if tmp >= n:
    break
    
  tmp += k - 1
  ans += 1
  
print(ans)

Submission status: Accepted

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())

n,k = map(int, stdin.readline().rstrip().split())
A = list(map(int, stdin.readline().rstrip().split()))

if n == k:
    print(1)
elif (n-k)%(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()))
print(-(-(n-1)//(k-1)))

Submission status: Accepted

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

while True:
    cnt += 1
    tmp = ((K - 1) * cnt) + 1
    if N <= tmp:
        break
print(cnt)

Submission status: Accepted

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

print(ans)

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 os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

j = A.index(min(A))

l = math.ceil((j + 1) / K)
n = l * (K - 1) + 1
r = math.ceil((N - n) / (K - 1))
ans = l + r
#print(l, r, n)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


def main():
    n, k = input_list()
    a = input_list()
    a = math.ceil((n-k)/(k-1))
    print(1+a)


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    a=lmis()
    print(-(-(n-1)//(k-1)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
n,k = [int(e) for e in input().split(" ")[:2]]
input()
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
import math

def input_num():
	ls = input().strip().split(" ")
	return [int(e) for e in ls]

n,k = input_num()
a_ls = input_num()
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
A = iil()
print((n+k-3)//(k-1))

Submission status: Accepted

Solution code:
import math

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

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

emin = 100001
cont = 0
for ea in a:
    emin = min(emin, ea)

for i in range(len(a)):
    if i + 1 < len(a) and a[i] == emin and a[i + 1] == emin:
        cont += 1

all = 1 + math.ceil((n - k) / (k - 1))
con = 1 + math.ceil(math.floor(cont + 1 - k) / (k - 1))

print(all - con)

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
tmp = K
time = 1
while(tmp<N):
    tmp += K-1
    time += 1
print(time)

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:
#!/usr/bin/env python3
n, k = map(int, input().split())
print(0--~-n//~-k)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/arc099/tasks/arc099_a
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]

ans = (len(nums) - 1) // (k - 1)
if (len(nums) - 1) % (k - 1) != 0:
    ans += 1
print(ans)

Submission status: Accepted

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


def solve(N: int, K: int, A: "List[int]"):
    # if N % (K - 1) in (0, 1):
    #     print(N // (K-1))
    #     return
    print((N-1) // (K-1) + (1 if (N-1) % (K-1) else 0))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
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:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   return ceil((N - 1)/(K - 1))


def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
c = A.count(min(A))
if c == N:
    print(0)
else:
    print(max(1, 1 + math.ceil((N - K) / (K - 1)) - (c - 1)))

Submission status: Accepted

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

    num = min(a)
    num_c = a.count(num)
    ans = -(-(len(a)-num_c)//(k-1))

    return ans

    
print(solve())

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    A = readInts()
    res = 0
    ans = 0
    while True:
        if res == 0:
            res += k
        else:
            res += k-1
        ans += 1
        if res >= n:
            break
    print(ans)
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 - k) / (k - 1)) + 1)

Submission status: Accepted

Solution code:
import numpy as np

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

Submission status: Accepted

Solution code:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   return ceil((N-1) /(K - 1))

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Accepted

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

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

Submission status: Accepted

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

"1 2 3 4 5を配列に"
A = list(map(int, input().split()))
A.sort()
count = A.count(A[0])
remain = len(A) - count
if remain % (K-1) == 0:
  print(remain//(K-1))
else:
  print((remain//(K-1))+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
ans = ceil((N-1)/(K-1))
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

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,k=map(int,input().split())
print((1-n)//(k-1)*-1)

Submission status: Accepted

Solution code:
import math
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
len_a = len(a_list)
if len_a <= k:
    print(1)
else:
    ans = len_a - k
    print(math.ceil(ans / (k-1))  + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def main():
    N, K = map(int, input().split(' '))
    An = list(map(int, input().split(' ')))
    
    # N, K = 4, 3
    # An = [2, 3, 1, 4]
    
    # N, K = 8, 3
    # An = [7, 3, 1, 8, 4, 6, 2, 5]
    
    
    num = len(An)
    
    # print(num // (K-1))
    
    # for i in range(0, len(An), K-1):
    #     print(i)
    out = (N - 1) / (K - 1)
    print(math.ceil(out))
    
main()

Submission status: Accepted

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

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

ans += (-(-((n-1) - ans*(k-1)) // (k-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) +  1*((n-1)%(k-1)!=0)
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(1, N + 1):
    if K * i - (i - 1) >= N:
        print(i)
        break

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:
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:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=math.ceil((n-1)/(k-1))
print(c)

Submission status: Accepted

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

idx_1 = A.index(1)
ckpt = 0
ans = 0
for i in range(0, idx_1 + 1, K - 1):
    ans += 1
    if i <= idx_1 and idx_1 <= i + K - 1:
        ckpt = i + K - 1
        break
if ckpt < N - 1:
    for i in range(ckpt, N, K - 1):
        if len(A[i:i + K]) > 1:
            ans += 1
print(ans)

Submission status: Accepted

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

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:
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
m = a.index(1)
ans = 0
a = m//(k-1)
ans += a+1
s = (k-1-m%(k-1))+m
l = n-1-s
if l!=0:
  ans += (l-1)//(k-1)+1
if m == 0:
  ans = (n-2)//(k-1)+1
if n==k:
  ans = 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
print(-(-(N - M) // (M - 1)) + 1)

Submission status: Accepted

Solution code:
n, k, *a = map(int, open(0).read().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 = list(map(int, input().split()))
A = list(map(int, input().split()))
I = A.index(1)
l = (I + K-2)//(K-1) if I != K else 1
J = l*(K-1)
r = (N-1 - J + K-2)//(K-1) if (N-1-J) != K else 1
# print(I, l, J, r)
print(l+r)

Submission status: Accepted

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

Submission status: Accepted

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

if n == k:
    print(1)
else:
    ans = (n - 1) // (k - 1)
    if not (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()))
print(math.ceil((n-k)/(k-1))+1)

Submission status: Accepted

Solution code:
def main():
    from math import ceil

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

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

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

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

else:
  ans = 2 + (n-k) // (k-1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Nagasa = len(L)

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

Submission status: Accepted

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

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

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

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, k = map(int, input().split())
print(-(-(n-1)//(k-1)))

Submission status: Accepted

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

Submission status: Accepted

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

left=0
right=0
for i in range(N):
  if A[i]==1:
    left=i
    right=N-(i+1)
ans=ceil((left+right)/(K-1))
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
if (n-1)%(k-1)!=0:
    ans = (n-1)//(k-1)+1
else:
    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 = (n+k-3)//(k-1)
print(ans)

Submission status: Accepted

Solution code:
import sys
from math import ceil

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

if N == K:
    print(1)
    sys.exit()

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

Submission status: Accepted

Solution code:
from math import ceil
n, k = map(int, input().split())
nums = list(map(int, input().split()))
same = k
ans = 1
if same < n:
    ans += ceil((n - same) / (k - 1))
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
def examA():
    N, M = LI()
    l = 1; r = N
    for _ in range(M):
        L, R = LI()
        l = max(L,l)
        r = min(R,r)
    ans = max(0,r-l+1)
    print(ans)
    return

def examB():
    N = I()
    S = [I()for _ in range(N)]
    rest = []
    for s in S:
        if s%10==0:
            continue
        rest.append(s)
    if sum(S)%10==0:
        if not rest:
            print(0)
            return
        ans = sum(S) - min(rest)
    else:
        ans = sum(S)
    print(ans)
    return

def examC():
    N, K = LI()
    K -= 1
    A = LI()
    L = A.index(1)
    #print(L)
    ans = (N-1+K-1)//K
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return read().rstrip().decode('utf-8')
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    target = float("inf")
    target_index = []
    for i in range(n):
        if a[i] < target:
            target = a[i]
            target_index.append(i)
    answer = float("inf")
    for t in target_index:
        answer = min(answer, ceil(t / (k - 1)) + ceil((n - t - 1) / (k - 1)))
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

def ceil(a, b):
   return a // b + (a % b > 0)
n -= k
print(ceil(n, k-1) + 1)

Submission status: Accepted

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

"1 2 3 4 5を配列に"
A = list(map(int, input().split()))
A.sort()
count = A.count(A[0])
remain = len(A) - count
if remain % (K-1) == 0:
  print(remain//(K-1))
else:
  print((remain//(K-1))+1)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    tolerance = (k - 1)
    cnt = 0
    for i in range(1, n + 10):
        if k + tolerance * (i - 1) < n:
            cnt += 1
        else:
            cnt += 1
            break

    print(cnt)

Submission status: Accepted

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

cnt = 0
if((len(A)-K)%(K-1) == 0):
    ans = 1 + (len(A)-K)//(K-1)
else:
    ans = 1 + (len(A)-K)//(K-1)+1
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Accepted

Solution code:
n,k = (int(x) for x in input().split())
input()
ans =(n-1+k-2) // (k-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:
N, K = map(int, input().split())
A = list(map(int, input().split()))

a = A.index(1)
ans = int((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()))

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

print(answer)

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(2 + (n - k) // (k - 1))

Submission status: Accepted

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

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:
def main():
    n, k = list(map(int, input().split()))
    ans = (n - 1) // (k - 1)
    if (n - 1) % (k - 1) == 0:
        print(ans)
    else:
        print(ans + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
while True:
  if ans*K - ans + 1 >= N:
    print(ans)
    break
  else:
    ans += 1

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, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
def ceil(x,y):
  return (x-1)//y+1

n,k = map(int,input().split())
A = list(map(int,input().split()))
for i,ai in enumerate(A):
  if ai == 1:
    ind1 = i
print(ceil(n-1,k-1))

Submission status: Accepted

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

Submission status: Accepted

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

if n == k:
  ans = 1
else:
  ans = (n - 2) // (k - 1) + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:

#C - Minimization
import math
N,K = map(int, input().split())
A = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import math
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:
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 1
N -= K
K -= 1

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