Problem:


Score : 300 points

Problem Statement

There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.

On this sequence, Snuke can perform the following operation:

Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.

Constraints

2 \leq K \leq N \leq 100000

A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.

In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Accepted

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

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

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

Submission status: Accepted

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

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

print(count)

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()))
cover = K
ans = 1
while cover < N:
    cover += (K-1)
    ans += 1
print(ans)

Submission status: Accepted

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

if n==k:print(ans)

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

Submission status: Accepted

Solution code:
#ABC101C
N, K=map(int, input().split())
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 numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))

# (N-1)/(K-1)
res = int(np.ceil((n-1)/(k-1)))

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-chk-1
ans=((l+k-1)//k)+((r+k-1)//k)

if l%k==0:
    t1=0
else:
    t1=k-(l%k)
ans=min(ans,((l+k-1)//k)+((r-t1+k-1)//k))

if r%k==0:
    t2=0
else:
    t2=k-(r%k)
ans=min(ans,((l-t2+k-1)//k)+((r+k-1)//k))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
iN,iK = [int(_) for  _ in  input().split()]
#aA = [int(_) for  _ in  input().split()]
def fCeil(n,k):
    if n % k :
        return n // k + 1
    else:
        return n // k
print(fCeil(iN-1,(iK-1)))

Submission status: Accepted

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

i1 = A.index(1)
d1, m1 = divmod(i1, K - 1)

r = i1 + 1
if m1 != 0:
    r += K - 1 - m1

d2, m2 = divmod(max(0, N - r), K - 1)

print(d1 + d2 + (m1 != 0) + (m2 != 0))

Submission status: Accepted

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

Submission status: Accepted

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

n,k=map(int,input().split())
l=list(map(int,input().split()))
m=n-k
a=0
while m>0:
    m-=k-1
    a+=1
print(a+1)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())

array = np.array(list(map(int, input().split())))

cnt = 0
sum_ans = K
while True:
    if sum_ans >= N:
        cnt += 1
        break
    else:
        sum_ans += K-1
        cnt += 1

print(cnt)

Submission status: Accepted

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

a = [int(m) for m in a]
t = a.index(min(a))

leftar = []
rightar = []
leftco = 0
rightco = 0
startco = 1
#左側
for i in range(1, k + 1):
    if (t - k + i) / (k - 1) <= 0:#マイナス、０のときは０とする
        leftar.append(leftco)
    elif (t - k + i) % (k - 1) == 0:
        p = int((t - k + i) / (k - 1))
        for j in range(1, p + 1):
            leftco += 1
        leftar.append(leftco)
        leftco = 0
    else:#割り切れないときは繰り上げ
        p = int((t - k + i) / (k - 1)) + 1
        for j in range(1, p + 1):
            leftco += 1
        leftar.append(leftco)
        leftco = 0
#右側
for i in range(1, k + 1):
    if (n - t - i) / (k - 1) <= 0:
        rightar.append(rightco)
    if (n - t - i) % (k - 1) == 0:
        q = int((n - t - i) / (k - 1))
        for j in range(1, q + 1):
            rightco += 1
        rightar.append(rightco)
        rightco = 0
    else:
        q = int((n - t - i) / (k - 1)) + 1
        for j in range(1, q + 1):
            rightco += 1
        rightar.append(rightco)
        rightco = 0

sumar = [x + y + startco for (x, y) in zip(leftar, rightar)]

print(min(sumar))

Submission status: Accepted

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

while n > k:
    n -= k - 1
    count += 1

count += 1
print(count)

Submission status: Accepted

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

while n > k:
    n -= k - 1
    count += 1

count += 1
print(count)

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

Submission status: Accepted

Solution code:
import sys


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

if k == 2:
    print(n-1)
    sys.exit()

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

Submission status: Accepted

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

n, k = [int(x) for x in input().split()]
alist = [int(x) for x in input().split()]
ans = int((n-1) / (k-1))
if (n-1) % (k-1) != 0:
    ans += 1
print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N == K:
    print(1)
elif N / 2 < K:
    print(2)
else:
    ans = 1
    num = 0
    num += K
    while num < N:
        num += K - 1
        ans += 1
    print(ans)

Submission status: Accepted

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


def main():
    from math import ceil

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

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

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

Submission status: Accepted

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

while A_len > 0:
    A_len -= K - 1
    count += 1

print(count)

Submission status: Accepted

Solution code:
import math

n, k = [int(v) for v in input().split()]
a = [int(v) for v 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()))
cnt = 0

res = len(a)

while True:
	if res <= 1:
		print(cnt)
		exit()
	res = res - (K-1)
	cnt += 1

Submission status: Accepted

Solution code:
import math

N, K = [int(x) for x in 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())
a = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

minA = min(A)
toflat = N - A.count(minA)

print(-(-toflat // (K - 1)))

Submission status: Accepted

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

list_a = []
for part in input().split():
    list_a.append(int(part))

a_len = len(list_a) - K
cnt = 1
while True:

    if (K-1) <= a_len:
        a_len -= K - 1
        cnt += 1    
    else:
        if a_len != 0:
            cnt += 1
        break

print(cnt)

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:
# -*- coding: utf-8 -*-
"""
C - Minimization
https://beta.atcoder.jp/contests/abc101/tasks/arc099_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, K, arr):
    ans = 1
    while N > K:
        N -= (K - 1)
        ans += 1
    return ans


def main(args):
    N, K = map(int, input().split())
    arr = [int(a) for a in input().split()]
    ans = solve(N, K, arr)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
data = input().split()
data_set = set(data)
print((len(data_set)-1)//(K-1) + 1 * bool((len(data_set)-1)%(K-1)))

Submission status: Accepted

Solution code:
# coding:utf-8

import math


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


N, K = inpl()
A = inpl()

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

Submission status: Accepted

Solution code:
#coding: utf-8

n,k = map(int,raw_input().split())
s = raw_input()

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

Submission status: Accepted

Solution code:
def modnotzero(m, n):
	if m % n != 0: return 1
	else: return 0
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
pos = 0
for i in range(0, N):
	if A == 1: pos = i
left = pos
right = N - 1 - pos

min = N+1

for i in range(0, K):
	L = left - i
	R = right - K + 1 + i
	if L >= 0 and R >= 0:
		cnt = L/(K-1)+R/(K-1)+modnotzero(L, (K-1))+modnotzero(R, (K-1))
		if cnt < min: min = cnt

print min + 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()))

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
from math import ceil

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

print(ceil((len(A)-1)/(k-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
input()
if K >= N:
    print(1)
else:
    print(math.ceil((N - 1) / (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:
N,K = map(int,input().split())
A = list(map(int,input().split()))
if (N-1)%(K-1) != 0 :
    print((N-1)//(K-1)+1)
else :
    print((N-1)//(K-1))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
if n <= k:
    print(1)
else:
    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 = (N-1)/(K-1)
print(int(a) + (0 if int(a)==a else 1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
def kiriage(a, b): #切り上げ
    return (a + b - 1) // b

print(kiriage(N - 1, K - 1))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000)


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

tmp = K
count = 1

while tmp < N:
        tmp += K-1
        count += 1

print(count)

Submission status: Accepted

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

#m=A.index(1)

#le=m
#ri=n-m
#if le//(k-1)!=0 :
#    ri-=(k-1)-le%(k-1)

#print(le//(k-1)+ri//(k-1))

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

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
A = [int(i) for i in list(input().split())]

print(int(np.ceil((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) + bool((N-1)%(K-1)))

Submission status: Accepted

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

ans = 1
cover = K
while True:
    if cover >= N:
        print(ans)
        exit()
    cover += K-1
    ans += 1

Submission status: Accepted

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

def f():
  for i in range(1, N+1):
    if (K-1)*i + 1 >= N:
      return i
print(f())

Submission status: Accepted

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

def f():
  for i in range(1, N+1):
    if (K-1)*i + 1 >= N:
      return i
print(f())

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = [int(x) for x in input().split()]
ext = k - 1
lest = len(a) - 1
cnt = 0
while lest > 0:
  lest -= ext
  cnt += 1
print(cnt)

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

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

input()

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

Submission status: Accepted

Solution code:
# coding: utf-8

from math import ceil

def solve(N, K):
    return ceil((N-1) / (K-1))

if __name__ == "__main__":

    N, K = [int(x) for x in input().split()]
    Ai = [int(x) for x in input().split()]
    print(solve(N, K))

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n, k = [int(x) for x in input().split()]
a = [int(x) for x 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()))

amin = min(a)

if len(a) == a.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - a.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(g)

Submission status: Accepted

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

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

Submission status: Accepted

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

import math

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


import math


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

Submission status: Accepted

Solution code:
import math

n,k = map(int,input().split())
input()
print(math.ceil((n-1)/float(k-1)))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

num = ceil((N-1)/(K-1))

print(num)

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
n=l[0]
k=l[1]
ll=list(map(int,input().split()))
#q=ll.index(1)
print((n+k-3)//(k-1))

Submission status: Accepted

Solution code:
import math

def C(n,k):
    result = math.ceil((n-1)/(k-1))
    print(result)

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for g in range(1,n+1):
    if n<=g*(k-1)+1:
        print(g)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math
#import pdb

tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

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

Submission status: Accepted

Solution code:
# グループ分けの数を最初に分かっていれば、いい
n, k = map(int, input().split())
a_tmp = input().split()
a = []
for _ in a_tmp:
    a.append(int(_))
g = 1
while n > (k + (k-1)*(g-1)):
    g += 1
print(g)

Submission status: Accepted

Solution code:
import math
header = [int(n) for n in input().split()]
dataLength = header[0]
subsetLength = header[1]
print(int(math.ceil((dataLength-1)/ (subsetLength-1))))

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    N, K = [int(_) for _ in input().split()]
    A = [int(_) for _ in input().split()]

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

    print(ans)

    # min_num_idx = A.index(min(A))

    # ans1 = 0

    # left_idx = min_num_idx
    # while left_idx > 0:
    #     ans += 1
    #     left_idx -= (K - 1)

    # right_idx = min_num_idx
    # while right_idx < (N - 1):
    #     ans += 1
    #     right_idx += (K - 1)

    # print(ans)

main()

Submission status: Accepted

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

def main():
	N, K = map(int, input().split())
	lists = map(int, input().split())
	
	print(1-(-(N-K)//(K-1)))
	


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import math
print((lambda x:math.ceil((int(x[0])-1)/(int(x[1])-1)))(input().split()))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = [int(i) for i in input().split()]
if (len(l) - K) % (K - 1) == 0:
    print(int((len(l) - K) / (K - 1)) + 1)
else:
    print(int((len(l) - K) / (K - 1)) + 2)

Submission status: Accepted

Solution code:
from math import ceil

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

index_min = A.index(1)
if not index_min % (k - 1) == 0:
    index_min = (index_min // (k - 1) + 1) * (k - 1)
index_min = min(index_min, n-1)

ans = ceil(index_min / (k - 1))
ans += ceil((n - index_min - 1) / (k - 1))

print(ans)

Submission status: Accepted

Solution code:
# your code goes here

N,K = map(int,input().split())
li = list(map(int,input().split()))	
if N == K:
	print(1)
	quit()
i = 1
N = N-K

while N >= K:
	N = N - K +1
	i = i + 1

print(i+1)

Submission status: Accepted

Solution code:
n, k = input().split(" ")
n = int(n)
k = int(k)
a = input()
print(-(-(n - 1) // (k - 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:
N, K = map(int, input().split(" "))
if (N-1) / (K-1) == int((N-1) / (K-1)):
  ans = int((N-1)/(K-1))
else:
  ans = int((N-1)/(K-1)) + 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

flag = 1
cnt = 0
while flag < n:
    flag += 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()))
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
# coding: utf-8

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:
import math
N = input().split()
K = int(N[1])
Z = int(N[0]) - K
print(math.ceil(Z / (K - 1))+ 1)

Submission status: Accepted

Solution code:
import sys

def main():
    N, K = map(int, raw_input().split(' '))
    A = map(int, raw_input().split(' '))

    position_1 = A.index(1)
    if position_1 <= K or N-K <= position_1:
        if (N-K) % (K-1) > 0:
            print 1 + (N-K)/(K-1) + 1
            return
        else:
            print 1 + (N-K)/(K-1)
            return

    minimum = sys.maxint
    for i in range(K):
        total = 1
        smaller_A = A[:position_1-K+1]
        bigger_A = A[position_1+i:]

        if len(smaller_A) % (K-1) == 0:
            total += len(smaller_A) / (K-1)
        else:
            total += (len(smaller_A) / (K-1)) + 1
        
        if len(bigger_A) % (K-1) == 0:
            total += len(bigger_A) / (K-1)
        else:
            total += (len(bigger_A) / (K-1)) + 1

        if total < minimum:
            minimum = total

    print total

main()

Submission status: Accepted

Solution code:
import math
(n,k) = input().split(" ")
n=int(n)
k=int(k)
arr = input().split(" ")

idx = arr.index("1")
if idx < k or n-idx-1 < k:
    num=math.ceil((n-k)/(k-1))+1
else:
    num1 = math.ceil((idx+1)/k)
    idx1=k+(k-1)*(num1-1)-1
    num = num1+math.ceil((n-idx1-k)/(k-1))+1
print(num)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    m = min(A)
    mi = A.index(m)
    c = (N - 1) // (K - 1)
    if (N - 1) % (K - 1) > 0: c += 1
    print(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    m = min(A)
    mi = A.index(m)
    c = 0
    c += (N - 1) // (K - 1)
    if (N - 1) % (K - 1) > 0: c += 1
    print(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:


s = input()
splited = s.split(" ")

n = int(splited[0])
k = int(splited[1])

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


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

print(a)

Submission status: Accepted

Solution code:
import sys
N,K = map(int,input().split())
A = list(map(int,input().split()))
place_one = A.index(1)

if (N-1)%(K-1)!=0:
    print((N-1)//(K-1)+1)
    sys.exit()
else:
    print((N-1)//(K-1))
    sys.exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))

Submission status: Accepted

Solution code:
import math

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

i=0
while True:
    if n <= k:
        i+=1
        break
    i += n // k
    n = n // k + n % k

print(i)

Submission status: Accepted

Solution code:
nk=input().split()
l=input().split()

nk_i=[int(s) for s in nk]
N=nk_i[0]
K=nk_i[1]

l_i=[int(s) for s in l]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

print(ans)