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:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    x=A.index(1)+1
    ans=0
    ans+=-(-(x-1)//(K-1))
    x=-(-(x-1)//(K-1))*(K-1)+1
    ans+=-(-(N-x)//(K-1))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
r = ans = 0
while r < N-1:
    ans += 1
    r += (K-1)
print(ans)

Submission status: Accepted

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

ans = 1
N -= K

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())
_ = [int(i) for i in input().split()]

cnt = 0
now = 1
while now < N:
    now += K - 1
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
a = LIST()
print((n - 1 + k - 2) // (k - 1))

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## デバッグ用
GBN_DEBUG = False
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
N, K = map(int, input().split())
#W = [input() for _ in range(N)]
A = list(map(int, input().split()))

#GBN_DEBUG = True

pos1 = 0 # 1の位置
for i in range(N):
    if A[i] == 1:
        pos1 = i
        break

numReplace = K - 1 # 1度に置き換えれる数

left = pos1 // numReplace # １より左を全て１にするのに必要な回数
if pos1 % numReplace != 0:
    left += 1
    pos1 = left * numReplace # 左を全て1にした場合に取り得る1の右端位置
                             # 元の1の位置より右にずれる（場合がある）

N_P_1 = N - pos1 - 1 
right = N_P_1 // numReplace # 1より右を全て１にするのに必要な回数
if N_P_1 % numReplace != 0:
    right += 1

print(left + right)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, K = (int(i)-1 for i in input().split())
    _ = [int(i) for i in input().split()]
    print((N + K - 1)//K)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    mi = min(A)
    idx = A.index(mi)
    h1 = idx
    h2 = N - idx - 1
    ans = N
    for k in range(K):
        cur = (max(0, (h1 - k))+(K-1)-1)//(K-1) + \
            (max(0, (h2 - ((K-1) - k)))+(K-1)-1)//(K-1) + 1
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    l = A.index(1)
    count = 1
    
    r = K - 1
    while r < l:
        r += (K - 1)
        count += 1
    
    if r < N - 1:
        ll = N - K
        count += 1
        while ll > r:
            ll -= (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()))
ans = (n+k-3)//(k-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 - k) / (k - 1)) + 1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
j = K-1
l = i
r = N - l - 1
ans, e = divmod(l, j)
if e:
    ans += 1
    r -= K - e - 1
ans += (r+j-1)//j
print(ans)

Submission status: Accepted

Solution code:
# Problem C - Minimization

import math

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

# output
ans = math.ceil((N - 1) / (K - 1))
print("%d"%(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
now = 1
while True:
    now += K - 1
    ans += 1

    if now >= N:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,k = map(int, input().split())
a = list(map(int,input().split()))
for i in range(n):
    if n/(k+((k-1)*i)) <= 1:
        print(i+1)
        break

Submission status: Accepted

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

index = A.index(1)  + 1

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

print(ans)

Submission status: Accepted

Solution code:
import math

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

mi = min(A)
cnt = A.count(mi)
print(math.ceil((n-cnt)/(k-1)))

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

p = 0
for k in range(N):
    if A[k] == 1:
        p = k+1
        break

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  n,k = input_list()
  a = input_list()
  ans = 0
  r = 1
  while True:
    r += k-1
    ans += 1
    if r >= n:
      break
  print(ans)
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    x=i
    y=n-1-i
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
mini=100000
p=0
for i in range(N):
  if mini>A[i]:
    mini=A[i]
    p=i+1
a=-(-(p-1)//(K-1))
b=-(-(N-(K-1)*a-1)//(K-1))
c=-(-(N-p)//(K-1))
d=-(-(N-c*(K-1)-1)//(K-1))
print(min((a+b),(c+d)))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
idx = k
r = 1
while idx < n:
    idx += k - 1
    r += 1
print(r)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
idx = r = 0
while idx < n:
    if idx == 0: idx += k
    else: idx += k - 1
    r += 1
print(r)

Submission status: Accepted

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

i = dat.index(1) + 1 # 1 origin で i 個目に 1 がある

reached = k # 最初の1歩はkマス塗れる
# a: 残りはk-1マス塗れるので、残っている分を塗る(k<nなのでマイナスは考えない)
a = math.ceil((n - reached) / (k - 1))
print(1 + a)

Submission status: Accepted

Solution code:
import math
n, k = map(int,input().split())
dat = list(map(int, input().split()))
i = dat.index(1) + 1 # 1 origin で i 個目に 1 がある
reach = k # 今1で占有した場所
a = math.ceil((n - reach) / (k - 1))
print(1+a)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
dat = list(map(int, input().split()))
i = dat.index(1) + 1 # 1originでi個目に1がある
import math

b1 = k # 今1で占有した場所
a1 = 1 # 1にたどり着くまでに必要な個数
a2 = 0
if b1 < i: # もし、iがいまよりも手前にあるなら
    a2 += math.ceil( (i - k) / (k - 1) )
b1 += a2 * (k - 1)
b1 = n if b1 > n else b1 # 1のターンでたどり着いた場所
a3 = math.ceil((n - b1) / (k - 1))
print(a1+a2+a3)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

Solution code:
from math import ceil
N,K=map(int,input().split())
_=[i for i in input().split()]
print(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()))
for i in range(n):
        if (k-1)*(i-1) + k >= n:
                print(i)
                break

Submission status: Accepted

Solution code:
from math import ceil

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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 = [int(x) for x in input().split()]
print((N + K - 3)//(K - 1))

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
r = -1
l = -1
for i in range(N):
    if A_lst[i] == 1:
        r = i
        l = N - i - 1
print((r + l + K - 2)//(K - 1))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()))

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    A = Scanner.map_int()
    print(Math.roundUp(N-1, (K - 1)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, K = list(map(int, sys.stdin.buffer.readline().split()))
_ = list(map(int, sys.stdin.buffer.readline().split()))

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

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from math import ceil

n, k = na()
a = na()

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
x = A.index(1)
y = len(A[:x]) // (K - 1)
z = len(A[x+1:]) // (K - 1)
ans += y + z
if y > 0:
    A = A[y*(K-1):]
if z > 0:
    A = A[:-1*z*(K-1)]
if len(A) == 1:
    ans += 0
elif len(A) <= K:
    ans += 1
else:
    ans += 2
#print(y,z,A)
print(ans)

Submission status: Accepted

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

s=(N-K)
print(s//(K-1) + (s%(K-1)>=1)*1 + 1)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
def solve():
    N, K, *A = map(int, open(0).read().split())

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

ans = N
for i in range(K):
    cnt = 1
    left = start + 1 - K + i
    if left > 0:
        if left % (K - 1) != 0: cnt += 1
        cnt += left // (K - 1)

    raight = N -1 - start - i
    if raight > 0:
        if raight % (K - 1) != 0: cnt += 1
        cnt += raight // (K - 1)
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

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

t = 1
while True:
    if 1 + t * (K - 1) >= N:
        break
    t += 1

print(t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n ,  k = map(int , input().split())
a = list(map(int, input().split()))
def rup(x, d):
	return (x + d - 1) // d

print(rup(n - 1 , k - 1))

Submission status: Accepted

Solution code:
import sys
from math import ceil
n, k = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
if n <= k:
    print(1)
else:
    n -= k
    print(ceil(n / (k - 1)) + 1)

Submission status: Accepted

Solution code:
a, b= map(int, input().split())
c = list(map(int, input().split()))
num = c.index(1)
left = num
right = a - left - 1
left_2 = left % (b - 1)
right_2 = right % (b - 1)
for i in range(b+1):
    if (left - i) % (b - 1) == 0:
        amari = (right - (b-1-i)) % (b - 1)
        kaisu_left = (left - i) // (b - 1)
        kaisu_right = (right - (b-1-i)) // (b - 1)
if amari == 0:
    print(kaisu_left + kaisu_right +1)        
if amari != 0:
    print(kaisu_left + kaisu_right +2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N, K, *A = map(int, open(0).read().split())
I = A.index(1)
print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

#並べえても結果は変わらない
s = k
for i in range(1, n+1):
    if s >= n:
        print(i)
        break
    else:
        s += (k - 1)

Submission status: Accepted

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

s = n-k

if s <= 0:
    print(1)
    exit()
    
tmp = s//(k-1)

if s%(k-1) != 0:
    tmp += 1

print(tmp+1)

Submission status: Accepted

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

i = a.index(1)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

m = math.ceil((n - 1) / (k - 1))  # (k - 1)*m + 1 >= n
print(m)

Submission status: Accepted

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

Submission status: Accepted

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


def contain(N, K, A, m, i):
    for j in range(i, min(i+K, N)):
        if A[j] == m:
            return True
    return False


def solve(N, K, A):
    m = min(A)
    a = 0
    i = 0

    while i < N:
        if A[i] == m:
            i += 1
        else:
            a += 1
            i += K + contain(N, K, A, m, i) - 2
            if i < N:
                A[i] = m
    return a


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    K = int(next(tokens))
    A = [int(next(tokens)) for _ in range(N)]
    print(solve(N, K, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int,input().split())
A = list(map(int,input().split()))
if K == 2:
    print(N - 1)
elif N % (K - 1) == 0 or N % (K - 1) == 1:
    print(N // (K - 1))
else:
    print((N // (K - 1)) + 1)

Submission status: Accepted

Solution code:
import math

N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
A=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき


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

Submission status: Accepted

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

cn = 1
n = n - k

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    n -= 1
    k -= 1
    print((n + k - 1) // k)


if __name__ == '__main__':
    slove()

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a,b = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

ans = 1 + int(math.ceil((a-b)/(b-1)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
if n == k:
         print(1)
         exit()
else:
         while k + (k-1)*i < n:
                  i += 1
print(i+1)

Submission status: Accepted

Solution code:
import math


def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    print(math.ceil((n - 1) / (k - 1)))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
def main():    
    n,k = map(int,input().split())
    _ = input()
    c = 1
    ans = 0
    while True:
        c += k-1
        ans += 1
        if c >= n:
            print(ans)
            break
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    print(((n-1) + (k-1) - 1) // (k-1))


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ARC099C
import sys

#n= int(input())
tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

tmp = input().split()
s = list(map(lambda a: int(a), tmp))

pos=tmp.index("1")
#print(tmp)
#print(tmp.index("1"))
#print(((pos)//k)+1)
#print(((n-pos-1)//k)+1)

if(k!=n):
	print((n-2)//(k-1)+1)
	#print(((pos)//k)+1+((n-pos-1)//k)+1)
else:
	print(1)

Submission status: Accepted

Solution code:
def ceil(a, b):
    return -(-a // b)


def main():
    n, k = map(int, input().split())
    print(ceil(n - 1, k - 1))


main()