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
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    LI()
    print((n - k) // (k - 1) + 1 + bool((n - k) % (k - 1)))
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()

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
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
n,k = ips()
a = iprow()
km = k-1
mp = a.index(1)
left = mp
right = n-mp-1
ans  = rem
for i in range(km):
    ap = 0
    lt = max(0,left-i)
    rt = max(0,right-(km-i))
    if lt % km == 0:
        ap += lt // km
    else:
        ap += lt // km + 1
    if rt % km == 0:
        ap += rt // km
    else:
        ap += rt // km + 1
    ans = min(ans,ap)
print(ans+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:
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 os, sys, re, math

lines = sys.stdin.readlines()

(n, k) = (int(d) for d in lines[0].split())
a = lines[1].split()

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

Submission status: Accepted

Solution code:
import math

b, c  = [int(a) for a in input().split()]
print (math.ceil((b - 1) / ((c - 1) * 1.0)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = (int(i) for i in input().split())
if n <= k:
  print(1)

else:
  ans = 1
  t = k
  while True:
    t = t + k - 1
    ans += 1
    if t >= n:
      break
    
  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:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, K = (int(_) for _ in input().split())
    A = list(int(_) for _ in input().split())
    
    print(math.ceil((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()))

p1 = A.index(1) + 1

l = (p1-1) // (K-1)
r = (N-p1) // (K-1)
amari = N - l*(K-1) - r*(K-1)

if N == K:
    ans = 1
elif N <= 2*K-1:
    ans = 2
elif amari == 1:
    ans = l + r
elif amari <= K:
    ans = l + r + 1
else:
    ans = l + r + 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8

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

for i in range(N):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i

    before = start
    after = N - (end+1)

    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1

    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1

    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))

Submission status: Accepted

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

ans = -(-(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()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 1回の操作ではK-1個の数を1にできる、変えなくてはいけない数はN-1個　その天井をとればok
import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = math.ceil((N - 1) / (K - 1))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 1
al = N - K
while al > 0:
    al -=  (K-1)
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [int(s) for s in 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()))

position = A.index(1)
counter = 0
# 左にposition個, 右に(N - position - 1)個の要素がある。
# 左
counter += position // (K - 1)
# 右
counter += (N - position - 1) // (K - 1)

amari = position % (K - 1) + (N - position - 1) % (K - 1)
if amari > 0: amari += 1
# print(amari)

counter += amari // K
if amari % K > 0: counter += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
from math import ceil
n, k = map(int, raw_input().split())
#arr = map(int, raw_input().split())
print max(1, int(ceil(float(n-1)/(k-1))))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
  if l[i]==1:c=i
l=i;r=n-i-1;ans=0
if l%(k-1)==0:ans-=1
if r%(k-1)==0:ans-=1
print(ans+l//(k-1)+r//(k-1)+2)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
count = 0
while n > 0:
    if count == 0:
        n -= k
        count += 1
    else:
        n -= (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()]
n -= 1
k -= 1
d = 0
if n % k:
  d = 1
print(n // k + d)

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

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

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

Submission status: Accepted

Solution code:
n, k = [ int(v) for v in input().split() ]
a = (n-1)//(k-1)
b = (n-1)%(k-1)

if b != 0:
    a += 1
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import math
N,K = [int(x) for x in stdin.readline().rstrip().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(1 + math.ceil((n-k) / (k-1)))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(N):
    if Alist[i]==1:
        cnt = i+1
        break

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

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:
n,k =map(int,input().split())
a = [int(x) for x in input().split()]
import math
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
import math


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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(1,n+1):
	l=k*i-(i-1)
	if l>=n:
		print(i)
		break

Submission status: Accepted

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

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

if a_lis.index(1) + 1 <= K or N - a_lis.index(1) <= K:
    if K == 2:
        print(N - 1)
        sys.exit()
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()
else:
    if K == 2:
        print(N - 1)
        sys.exit()
    print(math.ceil((N - K) / (K - 1)) + 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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

    pos = A.index(1)
    l = math.ceil(pos / (K - 1))
    r = math.ceil((N - 1 - l * (K - 1)) / (K - 1))
    print(int(l + r))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
n,k=map(int,input().split())
al=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()))
min_num = 10**9 + 10
count = 0

for i in range(0, n, k-1):
    check = a[i:i+k]
    num = min(a[i:i+k])
    if len(check) > 1:
        count += 1
    if num < min_num:
        min_num = num

print(count)

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)):
    ans += 1

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())
s = input()
print(-(-(n - 1) // (k - 1)))

Submission status: Accepted

Solution code:
import math

N,K=map(int,input().split())
A=[int(i) for i in 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()))
if K >= N:
    print(1)
else:
    res = (N - K) // (K - 1) + 1
    if (N - K) % (K - 1) != 0:
        res += 1
    print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n, k = map(int, input().split())
a_list = []
a_index = 0
for i, a in enumerate(input().split()):
    if a == 1:
        a_index = i
    a_list.append(a)

left = a_index
right = n - a_index - 1

# k-1ずつへる
print(math.ceil((left + right)/(k-1)))

Submission status: Accepted

Solution code:

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

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

"""

for i in range(len(A)):
    if A[i] == 1:
        point = i

left = point
right = N - point - 1

ans = 0

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

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

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

print (ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
i=0
while(1):
    if n <= k + (k-1)*i:
        print(i+1)
        break
    else:
        i+=1

Submission status: Accepted

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

now = K
i = 1
while now < N:
    now += K-1
    i += 1

print(i)

Submission status: Accepted

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

ans = 0
now = K
i = 1
while now < N:
    now += K-1
    i += 1

print(i)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  c=1
  n-=k

  while True:
    if n<=0:
      break

    n-=(k-1)
    c+=1

  return c

print(main())

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

a = len(A) - 1
b = K - 1

if a % b == 0:
    ans = a // b
else:
    ans = a // b + 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
x = a.index(1)
#if x % (k-1) + (n-k-1) % (k-1) > k-1:
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:
n, k = [int(v) for v in input().split()]
a_s = [int(v) for v in input().split()]

c1 = 1
n1 = k
c2 = (n - n1) // (k - 1)
n2 = c2 * (k-1)
n3 = n - n1 - n2
c3 = 1 if (n3 > 0) else 0
ans = c1 + c2 + c3
print(ans)

Submission status: Accepted

Solution code:
N, K = [int(nk) for nk in input().split()]
A = [int(a) for a 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 = [int(nk) for nk in input().split()]
A = [int(a) for a in input().split()]
N -= K
cnt = 1
while N > 0:
  N -= K-1
  cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b=LI()
  l=LI()

  c=1
  _b=b
  while True:
    if a<=_b:
      break
    else:
      _b+=b-1
      c+=1

  return c

print(main())

Submission status: Accepted

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

n = K
cnt = 1
while n < N:
    n += K-1
    cnt += 1
print(cnt)

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:
#!/usr/bin/env python
N, K = map(int, input().split())
ans = (N-1)/(K-1)
if ans % 1 == 0:
    print(int(ans))
else:
    ans += 1
    print(int(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	if K >= N:
		print(1)
		sys.exit()
		
	K -= 1
	tmp = 0
	if K != 1:
		if N % K == 0:
			tmp = N // K
		else:
			tmp = N // K
			tmptmp = N - (tmp * K)
			if tmptmp != 1:
				tmp += 1
	else:
		tmp = (N // K) -1
	
	print(tmp)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
# ARC099C - Minimization
from math import ceil

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

Submission status: Accepted

Solution code:
# ABC099C - Minimization
from math import ceil

N, K = list(map(int, input().rstrip().split()))
_ = list(map(int, input().rstrip().split()))
print(1 + ceil((N - K) / (K - 1)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    A_list = 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()))
c = 0 if (n-1)%(k-1)==0 else 1
ans = (n-1)//(k-1) + c
print(ans)

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

Solution code:
import math

[N,K]=[int(item) for item in input().split()]
A=[int(item) for item in input().split()]

if N<=K:
  print(1)
else:
  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())
print(int(np.ceil(((n-1) / (k-1)))))

Submission status: Accepted

Solution code:
from math import ceil

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

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

index = arr.index(1)

left = ceil(index / (k - 1))
left_used = (k - 1) * (left - 1) + k

right = ceil((n - left_used) / (k - 1))

print(left + right)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
print(1+math.ceil((n-k)/(k-1)))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

min_a = min(A)
ans = 1
tmp = K
while 1:
    if tmp >= N:
        break
    else:
        tmp += (K - 1)
        ans += 1
print(ans)

Submission status: Accepted

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


def solve(N: int, K: int, A: "List[int]"):
    if N <= K:
        print(1)
    else:
        cnt = 1
        n = N - K
        cnt += math.ceil(n/(K-1))
        print(cnt)
        
    


# Generated by 1.1.4 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)%1==0)):
    print(int((n-1)/(k-1)))
else:
    print(int((n-1)/(k-1))+1)

Submission status: Accepted

Solution code:
N, K, *a = map(int, open(0).read().split())
print((N - 2) // (K - 1) + 1)

Submission status: Accepted

Solution code:
import numpy as np 
n, k = map(int, input().split())
seq = list(map(int, input().split()))
index = [i for i in range(len(seq)) if seq[i]==1][0]
left = index
right = n - index - 1
#print(index, left, right)
time = int(np.ceil((left+right) / (k-1)))
print(time)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
    if A[i] == 1:
        break
ans = 10e9
left = len(A[:i])
right = len(A[i+1:])
for j in range(k):
    left_c = math.ceil((left-(k-1-j)) / (k-1))
    right_c = math.ceil((right-j) / (k-1))
    ans = min(ans, left_c+right_c)
print(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:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k = f()
    a = f()

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

solve()

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

Submission status: Accepted

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

for g in range(1,N):
  if K+(K-1)*(g-1) >= N:
    print(g)
    exit()

Submission status: Accepted

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

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

a = A.index(1)
#print (a)
#すべてindexで処理する
b = (a + 1 + K-2)//(K-1) #左端から1までの個数をKを1回ごとに進む数で割って切り上げ
#print (b)
c = b * (K-1) #上記の処理をしたときの右端のindex

if c >= (N-1): #右端のindexがリストの長さを超えている時
    print (b)
else: #右側にまだ数字が残っている時
    d = (N-1) - c #残っている数
    e = (d+(K-2))//(K-1)
    print (b + e)

Submission status: Accepted

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


def solve(N: int, K: int, A: "List[int]"):
    for i in range(1, N + 1):
        if K * i - (i - 1) >= N:
            ret = i
            break
    print(ret)
    return


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()