Problem:


Score : 300 points

Problem Statement

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

On this sequence, Snuke can perform the following operation:

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

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

Constraints

2 \leq K \leq N \leq 100000

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

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

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

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

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n, k = intin()
    alist = intina()

    for i, a in enumerate(alist):
        if a == 1:
            i1 = i
            break

    if i1 % (k - 1):
        left = i1 // (k - 1) + 1
    else:
        left = i1 // (k - 1)

    if left == 0:
        right_pos = n - 1
    else:
        right_pos = n - (left * (k - 1) + 1)

    if right_pos % (k - 1):
        right = right_pos // (k - 1) + 1
    else:
        right = right_pos // (k - 1)

    print(left + right)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

X = A[0]
index = 0
cnt = 0

while index < N:
    end_index = min(index + K, N)
    sub = [A[x] for x in range(index, end_index)]
    flag = 0
    for k in range(len(sub)):
        if sub[k] != X:
            A[k + index] = X
            flag += 1
    if flag != 0:
        cnt += 1
    index += K - 1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

idx = xs.index(1) # where 1 locates

result = N
for m in range(K):
  L = idx - m
  if L < 0:
    continue
  R = N - K - idx + m
  if R < 0:
    continue
  cnt = lambda a: 0 if a == 0 else math.ceil(a / (K -1))
  result = min(result, 1 + sum(cnt(b) for b in [L, R]))
  
print(result)

Submission status: Accepted

Solution code:
import math

def main():
    num, length = map(int, input().split())
    data = list(map(int, input().split()))

    ind = data.index(1)
    left = ind
    ans = math.ceil(left / (length - 1))
    right = num - (ans * (length - 1) + 1)
    if right > 0:
        ans += math.ceil(right / (length - 1))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

ans = 1

def dfs(N):
    global ans
    if N <= 0:
        return ans
    ans += 1
    return dfs(N-(K -1))

print(dfs(N-K))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

def dfs(N,ans):
    if N <= 0:
        return ans
    return dfs(N-(K -1),ans+1)

print(dfs(N-K,1))

Submission status: Accepted

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

ans = 1
N = N - K

while N > 0:
    N -= K-1
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def abc101_c():
    n, k = map(int, input().split())
    vs = list(map(int, input().split()))
    
    index = 0
    for i, v in enumerate(vs):
        if v == 1:
            index = i
            break
    len_l = index
    len_r = n - index - 1
    mod_l = len_l % (k-1)
    mod_r = len_r % (k-1)
    cnt_l = len_l // (k-1)
    cnt_r = len_r // (k-1)
    res = cnt_l + cnt_r
    if mod_l:
        res += 1
    if mod_r:
        res += 1
    if mod_l and mod_r and mod_l + mod_r <= (k-1):
        res -= 1
    return res
            
print(abc101_c())

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
lista = [int(i) for i in input().split()]
count = 1
if n==k:
    print(count)
else:
    rem = n-k
    count+=rem//(k-1)
    if rem%(k-1) != 0:
        count+=1
    print(count)

Submission status: Accepted

Solution code:
#C問題
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
ind=A.index(1)
ans=math.ceil((N-1)/(K-1))
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

ans = 1

temp = n-k

print(ans + math.ceil(temp/(k-1)))

Submission status: Accepted

Solution code:
import math
n, k = (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 ((n-1)%(k-1)) == 0:
        ans = int((n-1)/(k-1))
else :
    ans = int((n-1)/(k-1)) + 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, A: "List[int]"):
    minv = min(A)
    minvs = [i  for i, a in enumerate(A) if a == minv]
   
    c = 0
    ret = 0
    for p in minvs:
        if p <= c:
            c += 1
            continue

        n = (p - c + (K - 2)) // (K - 1)
        ret += n
        c += n * (K - 1)
        c = max(c, p) + 1
    c -= 1
    n = (N-1 - c + (K - 2)) // (K - 1)
    ret += n
    return ret


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]"
    result = solve(N, K, A)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

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



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

A_min = min(A)
for i in A:
    if A_min == i:
        N -= 1
print(math.ceil(N/(K-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
nums = list(map(int,input().split()))
center = nums.index(min(nums))
leftrem = center+1
rightrem = N-center

def g(n,k):
  ii = 0
  while True:
    if k<=(n+(n-1)*ii):
      return ii+1
    ii += 1

if N==K:
  print(1)
else:
  print(g(K,N))

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

Submission status: Accepted

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

	dev = (N-1)//(K-1)
	mod = (N-1)%(K-1)
	ans = dev
	if mod != 0:
		ans += 1

	print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N,K=map(int, input().split())
A = input().split()
l = A.index("1")
r = len(A) - l - 1

ama=l%(K-1)
l = max(l-ama, 0)
r = max(r-(K-1-ama), 0)

print(1+math.ceil(l/(K-1))+math.ceil(r/(K-1)))

Submission status: Accepted

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

ans = 0
N -= K
ans += 1 + N // (K-1)
if N % (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 <= K:
    print(1)
else:
    ans = 0
    N -= K
    ans += 1 + N // (K-1)
    if N % (K-1) > 0:
        ans += 1
    print(ans)

Submission status: Accepted

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

a = min(A)

count = 0
answer = 0

A.append(a)
for i in range(N+1):
    if A[i] == a:
        if count != 0:
            answer += math.ceil(count / (K-1))
            if count % (K-1) != 0:
                for j in range(1, K - (count % (K-1))):
                    if i+j < N+1:
                        A[i+j] = a
            count = 0
    else:
        count += 1

print(answer)

Submission status: Accepted

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

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(int,input().split())
print(math.ceil( (N-K)/(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-K)/(K-1) ) +1
print(ans)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(N: int, K: int, A: "List[int]"):
    print(int(math.ceil((N-1)/(K-1))))
    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()

Submission status: Accepted

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

i = A.index(min(A))
L = i
R = N - i - 1
out = (L+R-1)//(K-1) + 1
print(out)

Submission status: Accepted

Solution code:
line = input().split()
N = int(line[0])
K = int(line[1])

A = list(map(int, input().split()))
i = A.index(min(A))

b = (i+1)
a = (N-i)

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

Submission status: Accepted

Solution code:
import math

n,k = map(int,input().split())
list = [int(i) for i in input().split()]

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import math


nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
a = input().split()
min_i = a.index("1")
ans = 100000
for i in range(k):
    if (min_i - i) * (n - min_i + i - k) < 0:
        continue
    ans_i = math.ceil((min_i - i) / (k - 1)) + math.ceil((n - min_i + i - k) / (k - 1)) + 1
    if ans_i < ans:
        ans = ans_i
print(ans)

Submission status: Accepted

Solution code:
# 2019/04/09
# AtCoder Beginner Contest 103 - C

import math

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

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

# Output
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:
import sys
import math

input = sys.stdin.readline


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

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

m = n-k

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# if N <= K:
# 	print(1)
# else:
# 	print(ceil((N-K)/(K-1)) + 1)
print(ceil((N-K)/(K-1)) + 1)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    a, b = map(int, input().split())

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

    ans = (a-1)//(b-1) + bool((a-1) % (b-1))

    print(ans)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
A = [int(i) for i in input().split()]
count = 1
idx = K
while idx < N:
    idx += K - 1
    count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

n, k = MI()
a = LI()
cover = 0
ans = 0
while True:
    if cover == 0:
        cover += k
    else:
        cover += k-1
    ans += 1
    if n <= cover:
        break
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10**9
for i in range(1, K):
    count = 1 + (N - i - 1) // (K - 1)
    if (N - i - 1) % (K - 1):
        count += 1
    m = min(m, count)
print(m)

Submission status: Accepted

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

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

min_ind = A.index(1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import math

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
print(int((a-1)/(b-1)) if (a-1)%(b-1)==0 else (a-1)//(b-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())
A = list(map(int,input().split()))

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

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, K = 0, 0
A = []


def set_inputs():
    global N, K, A
    N, K = get_li()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    k = K - 1
    print(1 + ((N - K) + k - 1) // k)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,K = map(int,input().split())
num_array = [int(i) for i in input().split()]
min_num_index=num_array.index(1)
array_max_index=N-1
print(math.ceil((array_max_index)/(float(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 sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = input()
ans = (N - 1) // (K - 1)
if ans * (K - 1) < N - 1:
    print(ans + 1)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

inf = 10 ** 18

for i in range(1,inf):
  N -= (K - 1)
  if N <= 1:
    print(i)
    break

Submission status: Accepted

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

else:
#    print(Ain // (K - 1))
#    print((len(A)-(K - 1)* (Ain // (K - 1)) - 1))
    print(math.ceil(Ain / (K - 1)) + math.ceil((len(A)-(K - 1)* (math.ceil(Ain / (K - 1))) - 1) / (K-1)))

Submission status: Accepted

Solution code:
from collections import Counter
n, k = [int(elem) for elem in input().split()]
a_lst = [int(elem) for elem in input().split()]
minimum = min(a_lst)
num = n - Counter(a_lst)[minimum]

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

Submission status: Accepted

Solution code:
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmp=min(a)
count_min=Counter(a)[tmp]
kazu=n-count_min
if kazu%(k-1)==0:
    print(kazu//(k-1))
else:
    print(kazu//(k-1)+1)

Submission status: Accepted

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

min_place = a.index(1) + 1
left = math.ceil((min_place - 1) / (k-1)) 
left_lest = 0
if left != 0 and (min_place - 1) % (k-1) != 0:
  left_lest = (k-1) - (min_place - 1) % (k-1)
  
right = math.ceil((n - min_place - left_lest) / (k-1))
print(left + right)

Submission status: Accepted

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

i1 = A.index(1)

k0_min = max(i1 - K + 1, 0)
k0_max = min(i1, N - K)

nmin = N

for k0 in range(k0_min, k0_max+1):
    nl = -(-k0 // (K-1))
    nr = -(-(N-k0-K) // (K-1))
    n = nl + nr + 1
    nmin = min(n, nmin)

print(nmin)

Submission status: Accepted

Solution code:
m = input().split()
m1 = int(m[0])
m2 = int(m[1])
ans = 1

while(m1 > m2):
  m1 = m1 - m2
  m1 = m1 + 1
  ans = 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:
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(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,input().split())
A = list(map(int,input().split()))
print(ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
k,n=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(k,n,a)
count=1
lena=len(a)
while n < lena:
  lena=lena-n+1
  count+=1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math; print((lambda l: math.ceil((l[0] - 1) / (l[1] - 1)))(list(map(int, input().split()))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#  import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
#  sys.setrecursionlimit(10**7)
#  inf = 10 ** 20
#  eps = 1.0 / 10**10
#  mod = 10**9+7
#  dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
#  ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
#  def LI(): return [int(x) for x in sys.stdin.readline().split()]
#  def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
#  def LF(): return [float(x) for x in sys.stdin.readline().split()]
#  def LS(): return sys.stdin.readline().split()
#  def I(): return int(sys.stdin.readline())
#  def F(): return float(sys.stdin.readline())
#  def S(): return input()
#  def pf(s): return print(s, flush=True)

#  N, K = LI()
#  A = LI()

#  if N == K:
#      print(1)
#      exit()
#  N -= K
#  result = N / (K-1) + 1
#  if result % 1 != 0:
#      result //= 1
#      result += 1

#  print(int(result))



import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = int(result) + 1

print(int(result))

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

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

print(int(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import fractions
N, K = map(int, input().split())
A = list(map(int, input().split()))
# 最小的に最小値が並ぶことになる、最小値スタートが最短
start = A.index(1)
d1 = start - 0
d2 = N-1 - start
n = 0
m = 0
print(fractions.math.ceil((len(A)-1)/(K-1)))

Submission status: Accepted

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