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:
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,k=MI()
	A=LI()

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




if __name__ == "__main__":
	main()

Submission status: Accepted

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

a = len(A)
ans_1 = a - K
ans = 1 + math.ceil(ans_1/(K -1))
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
mi = A.count(min(A))
ans = (n - mi)//(k - 1)
if (n - mi)%(k - 1) != 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    if n == k:
        print(1)
    else:
        ans = ((n + (k - 3)) // (k-1))
        print(ans)
        

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

Submission status: Accepted

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

a = len(A)
ans_1 = a - K
ans = 1 + math.ceil(ans_1/(K -1))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

mini = min(A)
idx = N + 1
mid = N / 2

for i, a in enumerate(A):
  if a == mini and abs(idx - mid) > abs(i - mid):
    idx = i

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()
i = a.index(1)

x = i
y = n-i-1

from math import ceil

ans = float("inf")
for t in range(k):
	ans = min(ans,ceil((x-t)/(k-1))+ceil((y-k+t+1)/(k-1))+1)

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    As = [int(item) for item in input().split()]

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n,m = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
i = ar.index(1)
if n <= m:
    print(1)
    exit()
count = 0
am = 0
count += i // (m - 1)
am += i % (m - 1)
count += (n - 1 - i) // (m - 1)
am += (n - 1 - i) % (m - 1)
if am <= m - 1 and am > 0:
    count += 1
if am > m - 1:
    count += 2
print(count)

Submission status: Accepted

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

# In[12]:


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


# In[14]:


ans = (N-1)//(K-1) + min(1, (N-1)%(K-1))
print(ans)


# In[ ]:

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split());a = list(map(int,input().split()));ans = 0
 
for n in range(1,N):
  ans += 1
  a_n = K +(n-1)*(K-1)
  if a_n >= N:
    print(ans)
    exit()

Submission status: Accepted

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

# 最小値付近から攻める
idx = a.index(min(a))

ans = 10**12
for i in range(k):
    right = n - idx - 1 - i
    left = max(idx - k + 1 + i, 0)
    
    q1,r1 = divmod(left, k-1)
    q2,r2 = divmod(right, k-1)
    ans = min(ans, q1 + q2 + min(r1,1) + min(r2,1))

print(ans+1)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def li(): return map(int,sys.stdin.readline().rstrip().split())
def lf(): return map(float,sys.stdin.readline().rstrip().split())
def ls(): return sys.stdin.readline().rstrip().split()

n, k = li()
a = list(li())
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,k = lr()
a = lr()
ind = 0
p = inf
for i,num in enumerate(a):
    if num == 1:
        ind = i
for i in range(k):
    l = ind-i
    r = l+k-1
    ans = 1
    if l > 0:
        ans += (l+k-2)//(k-1)
    if r < n-1:
        ans += (n-r-1+k-2)//(k-1)
    p = min(ans,p)
print(p)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
while True:
  N=N-K
  cnt+=1
  if N<=0:
    break
  else:
    N=N+1
print(cnt)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lst=map(int,input().split())
ans=1
if n-k>0:
    ans+=(n-k)//(k-1)
    if (n-k)%(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()))
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()))

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lis = list(map(int, input().split()))
l = lis.index(1)
Lis = list(reversed(lis))
L = Lis.index(1)
i = 0
j = 0

if l + 1 >= K:
  r = (l + 1 - K) % (K - 1)
  if r != 0:
    r = K - 1 - r
else:
  r = K - l - 1
  
if L + 1 >= K:
  R = K - (L + 1 - K) % (K - 1)
  if R != 0:
    R = K - 1 - R
else:
  R = K - L - 1


if r >= R:
  if r == K - 1:
    r = 0
    
  while l - i * K + i > 0:
    i += 1

  while l + r + j * K - j < N - 1:
    j += 1
  
else:
  if R == K - 1:
    R = 0
    
  while L - i * K + i > 0:
    i += 1

  while L + R + j * K - j < N - 1:
    j += 1
  
print(max(1, i + j))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

if n == k:
    ans = 1 
elif (n-1)%(k-1)==0:
    ans = (n-1)//(k-1)
else:
    ans = math.ceil(n/(k-1))
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))     # このリストは使用しない

ans = 0
done = 1

while done < N:
    done += K - 1
    ans += 1

print(ans)

Submission status: Accepted

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


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def solve(N, K, A):
    ans = 1
    for i in range(K, N, K-1):
        ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
from math import ceil
n,k = map(int,input().split())
a=list(map(int,input().split()))
print(1+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()))
#index = a.index(1)
#left, right = index, n-index-1
#if n!=k: print(ceil(left/(k-1))+ceil(right/(k-1)))
if n!=k: print(1+ceil((n-k)/(k-1)))
else: print(1)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)
temp=np.argmin(a)
import math
if n==k:
  print(1)
else:
  print(math.ceil(temp/(k-1))+math.ceil((n-temp-1-(k-temp-1)%(k-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())
_ = input()
print(-(-(N-1)//(K-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()))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k, *_ = map(int, open(0).read().split())
print((n - 2) // (k - 1) + 1)

Submission status: Accepted

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

Submission status: Accepted

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

from math import ceil

if n <= k:
    print(1)
else:
    print(1+ceil((n-k)/(k-1)))

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
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
A = readInts()
cnt = 1
now = k
while now < n:
    cnt += 1
    now += k - 1
print(cnt)

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mid = A.index(1)
    count = 1
    r = K - 1
    while r < mid:
        r += (K - 1)
        count += 1

    if r < N - 1:
        l = N - K
        count += 1
        while l > r:
            l -= (K - 1)
            count += 1
    print(count)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
import math
if N == K:
  ans = 1
else:
  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()))
cnt = 1
n = (N-K)//(K-1)
if (N-K)%(K-1)==0:
    cnt += n
else:
    cnt += n+1
print(cnt)

Submission status: Accepted

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

mae = 0
ato = 0
bit = 0
for i in range(n):
    if a[i] != 1 and bit == 0:
        mae += 1
    elif a[i] != 1 and bit == 1:
        ato += 1
    else:
        bit = 1

waru = k-1
ans = (mae+ato+waru-1)//waru
print(ans)

Submission status: Accepted

Solution code:
from math import ceil

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

one = A.index(1)
print(ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
 
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] == 1:
        break
left = len(a[:i])
right = len(a[i + 1:])

ans = left // (k - 1) + right//(k - 1) + (left%(k-1) + right%(k-1))//(k-1) + int((left%(k-1) + right%(k-1))%(k - 1) != 0)

print(ans)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c=(a-1)//(b-1)
while (c+1)*(b-1)<=a-1:
  c+=1
if (a-1)%(b-1)!=0:
  c+=1
print(c)

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()))
print(ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
import math

N, K = map(lambda x: int(x)-1, input().split())
#A = list(map(int, input().split()))

print(math.ceil(N/K))

Submission status: Accepted

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

idx1=A.index(1)

from math import ceil

ans=10000000

for i in range(K):
  left=idx1-i
  right=left+K-1
  if left<0 or right>N-1:
    continue
  tmp=ceil(left/(K-1))+ceil((N-1-right)/(K-1))+1
  ans=min(ans, tmp)

print(ans)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

i = 0
count = 0
while True:
    if (i >= N - 1):
        break

    i += K - 1
    count += 1

print(count)

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()))
import math
if N==K:
  print(1)
else:
  ans=10**18
  for i in range(K-1):
    n=N-(K-i)
    ans=min(ans,math.ceil(n/(K-1))+1)
  print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 1
    field = K
    for i in range(N):
        if field >= N:
            break
        field += K-1
        cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
#最終的にすべて同じ値になるなら、最小値のほうから攻めるべき
#早いソートにしたほうがいいかも。2部探索とか
mini_index=A.index(1)
if N<=K:
    print(1)
else:
    length=K
    count=1
    while(True):
        length+=K-1
        count+=1
        if length>=N:
            print(count)
            break

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,k=l()
A=l()
y=min(A)
x=A.index(y)
ans=(n-2)//(k-1)+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:
N, K = map(int, input().split())
A = input()
ans = (N - 1) // (K - 1)
if (N - 1) % (K - 1) == 0:
    print(ans)
else:
    print(ans + 1)

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 I():
  return int(input())
n,k = readInts()
A = readInts()
import math
print(1 if len(A) <= k else 1 + math.ceil((n-k)/(k-1)))

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/arc099/tasks/arc099_a
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
import numpy as np
import math
import collections
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = math.ceil((n-k)/(k-1)+1)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    if N <= K:
        ans = 1
    else:
        ans = 1 + ((N-K)+K-2)//(K-1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math

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

count = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count+1)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, k = i_map()
    num_list = i_list()

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

    one_index = 0

    for i in range(n):
        if num_list[i] == 1:
            one_index = i
            break

    left_num = one_index
    right_num = n - one_index - 1

    count = 0

    left = left_num // (k-1)
    right = right_num // (k-1)

    count += left + right

    amari = n - 1 - (k-1) * (left+right)

    if amari > k - 1:
        count += 2
    elif amari == 0:
        pass
    else:
        count += 1
        
    print(count)

if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
def main():
    IN = [int(_) for _ in input().split()]
    K = IN[1]
    N = IN[0]
    A = [int(_) for _ in input().split()]

    if K >= N:
        print(1)
        return

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

import math
print( 1 + math.ceil( ( 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:
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
ans = 1 + (n-k)//(k-1)
if (n-k)%(k-1) != 0:
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
l = a.index(1)
r = n - l - 1
m = min(l, r)
print(math.ceil((n - 1) / (k - 1)))

Submission status: Accepted

Solution code:
import sys, math

N, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))

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

Submission status: Accepted

Solution code:
from math import ceil
N, K = map(int, input().split())
Alist = 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()))
y = int((N-K)/(K-1))
if ((N-K)%(K-1) == 0):
    x = 1 + y
else :
    x = 2 + y
print(x)

Submission status: Accepted

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

result=0

if N==K:
    result=1
else:
    result=(N-1)//(K-1)+((N-1)%(K-1)>0)*1

print(result)

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 = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
# print(f"N:{N} K:{K} A:{A}", file=sys.stderr)

zero_index = 0
for i in range(len(A)):
    if A[i] == 1:
        zero_index = i
        break

count = 0
### 1の右側を全部1にする回数を求める
### 右側から数えて K個, K-1個, ... K-1個 でzero_index に届く回数を確かめる
zero_left_index = len(A)

zero_left_index -= K
count += 1
while zero_left_index > zero_index:
    zero_left_index -= (K - 1)
    count += 1

# print(f"zero_index:{zero_index} count:{count} zero_left_index:{zero_left_index}", file=sys.stderr)

### zero_left_index(全部1になっている列の一番左) を全部1にする回数を求める
if zero_index != 1 and zero_left_index > 1:
    # zero_left_index -= K
    # count += 1
    while zero_left_index > 1:
        zero_left_index -= (K - 1)
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()


n -= k
k -= 1
print(n // k + (int(bool(n % k))) + 1)

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


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


def main():
    N, K = readnums()
    _ = readnums()
    print((N - 1) // (K - 1) + 1 if (N - 1) % (K - 1) else (N - 1) // (K - 1))


if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
a = list(map(int, input().split()))
result = 1
i = 0
while result < N:
    result += (K-1)
    i+=1
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#  C. Minimization
#  https://atcoder.jp/contests/arc099/tasks/arc099_a

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

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

print(ans)

Submission status: Accepted

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

Change = K - 1

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

Submission status: Accepted

Solution code:
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
    while True:
        if n<=k:
            cnt+=1
            print(cnt)
            break
        n -= k
        n += 1
        cnt += 1
resolve()