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())
alist=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()))
result = math.ceil((n-1)/(k-1))
print(result)

Submission status: Accepted

Solution code:
n,k = [int(i) for i in input().split()]
an = input()
count = 1
n -= k
k -= 1
while(n > 0):
    n -= k
    count += 1
print(count)

Submission status: Accepted

Solution code:
#!python3

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


def main():
    s = N - K
    k = K - 1
    ans = 1
    ans += s // k
    if s % k != 0:
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

    K -= 1
    a1_i = A.index(1)
    left = (a1_i + K - 1) // K
    right = (N - 1 - (left * K) + K - 1) // K
    print(left + right)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
import math
N, K = map(int, input().split())    

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

Submission status: Accepted

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

Amin = A.index(1)

left = len(A[:Amin])
right = len(A[Amin:])

ans = 0
if left <= right:
    ans += left // (k-1)
    right += left % (k-1)
    ans += ((right-1) + (k-2)) // (k-1)
else:
    ans += (right-1) // (k-1)
    left += right % (k-1)
    ans += (left + (k-2)) // (k-1)
print(ans)

Submission status: Accepted

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

if (A.index(1)+1)>=K and (N-A.index(1))>=K:
  ans=-(-A.index(1))//(K-1)-(-N+A.index(1)+1)//(K-1)
else:
  ans=1-(-N+K)//(K+1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(-(-(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:
n, k = map(int, input().split())
list_A = list(map(int, input().split()))
a = list_A.index(1) + 1
ans = 0
cnt = 0
amari = 0
if a == 1:
    ans += 0
else:
    ans += (a-1)//(k-1)
    if (a-1)%(k-1) != 0:
        ans += 1
        cnt += 1
        amari += (a-1)%(k-1)

if a == n:
    ans += 0
else:
    ans += (n-a)//(k-1)
    if (n-a)%(k-1) != 0:
        ans += 1
        cnt += 1
        amari += (n-a)%(k-1)

if cnt == 2 and amari <= k-1:
    ans -= 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
# coding: utf-8
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
cnt = 1
for i in range(1, N):
    if A[0] == A[i]:
        cnt += 1
print(ceil((N-cnt)/(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 a[i] == 1:
        m = i
        break
l = [m - k + 1, m]
ans = 114514
for i in range(k):
    x = l[0] + i
    y = l[1] + i
    if not x < 0 and not y >= n:
        c = 1
        while True:
            if x <= 0:
                break
            x -= k - 1
            c += 1
        while True:
            if y >= n - 1:
                break
            y += k - 1
            c += 1
        if c < ans:
            ans = c
print(ans)

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

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

print(ans)

Submission status: Accepted

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

if n<=0:
  pass
else:
  while n>0:
    n-=k
    count+=1
    
print(count)

Submission status: Accepted

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

num=0
while num*K-(num-1)<N:
    num+=1
print(num)

Submission status: Accepted

Solution code:
import math

def Minimization(n , k , al):

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

    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(Minimization(n , k , al))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

import bisect

# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd

import itertools

# from operator import attrgetter, itemgetter
import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    ans = 1
    rem = max(n - k, 0)
    ans += math.ceil(rem / (k - 1))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

# 1以外の要素n-1個を、k-1で割る(1項ずつ重複させるため)。余りは1回と数えるので、切り上げる
print(-((-n+1) // (k-1)))

Submission status: Accepted

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

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

if n == k:
    print(1)
elif k == 2:
    print(n-1)
else:
    rem = n % (k-1)
    m = (n - rem) / (k-1)
    if rem <= 1:
        print(int(m))
    else:
        print(int(m+1))

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

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    *a, = map(int, input().split())
    ans = 1
    n -= k
    while n > 0:
        ans += 1
        n -= k - 1
    return ans

print(main())

Submission status: Accepted

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

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

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


resolve()

Submission status: Accepted

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

ans = (N-1) // (M-1)

if (N-1) % (M-1) != 0:
  ans += 1
  
print(ans)

Submission status: Accepted

Solution code:


def solve():
    N, K = map(int, input().split())
    Ax = list(map(int, input().split()))
    if N == K:
        print(1)
        exit()

    N -= K
    ans = 1

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

    print(ans)


# Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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


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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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+K-3)//(K-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
k-=1
a=list(map(int, input().split()))
i=n-1
print(-(-i//k)-(-(n-i-1)//k))#pythonで切り上げの書き方

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n,k = map(int,input().strip().split())
    a = list(map(int, input().strip().split()))
    x_min=min(a)
    m=n
    for i in range(n):
        if a[i]==x_min:
            m-=1
    print(-(-m//(k-1)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 1 if n//k > 0 else 0 
mod = (n-k)//(k-1) + min((n-k)%(k-1), 1)
print(ans + mod)

Submission status: Accepted

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

## Trivial = (N-1)//(K-1)

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

Submission status: Accepted

Solution code:
from math import ceil

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

idx = A.index(1)

ans = N
for k in range(K + 1):
    L = idx - (K - k - 1)
    R = (N - 1 - idx) - k
    cntL = 0
    cntR = 0
    while L > 0:
        cntL += 1
        L -= K - 1
    while R > 0:
        cntR += 1
        R -= K - 1
    ans = min(ans, cntL + cntR + 1)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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


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

Submission status: Accepted

Solution code:
import math,sys

N, K = map(int, input().split())
window = K - 1
A = list(map(int, input().split()))
# mi_index = A.index(min(A))
# left_count = math.ceil(mi_index / (K - 1))
# right_count = math.ceil((N - (mi_index + 1)) / (K - 1))
# left = mi_index
# right = mi_index
# while left > 0 or right < N-1:
#   if left >= 0 and left > window:
#     left -= window
#   elif N - 1 - right >= window:
#     right += window
  
#   print(left, right)


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

print(count)

Submission status: Accepted

Solution code:
listlen, rensuu = map(int, input().split())
listnum = list(map(int, input().split()))
count = 0
count += (listlen - 1) // (rensuu - 1)
count += 1 if (listlen - 1) % (rensuu - 1) > 0 else 0
print(count)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,K = map(int,input().split())
L = [i for i in map(int,input().split())]
#if (N-1) % (K-1) != 0:
  #print(((N-1)//(K-1))+1)
#else:
  #print((N-1) % (K-1)) #equivalent to ceil.
print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

# a = list(map(int, input().split()))
n -= 1
k -= 1
ans = (n + k - 1) // k

print(ans)

Submission status: Accepted

Solution code:
import math

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

a = list(map(int, input().split()))
n -= 1
k -= 1
ans = (n + k - 1) // k

print(ans)

Submission status: Accepted

Solution code:
import math

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

a = list(map(int, input().split()))
n -= 1
k -= 1
ans = math.ceil(n / k)

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
minimum = 10**9
index = -1
for i in range(n):
  if minimum > a[i]:
    index = i
    minimum = a[i]
ans = 1+(i-1)//(k-1)+(n-i-1)//(k-1)
print(ans)

Submission status: Accepted

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

id_of_one = lst.index(1) #リスト内の最小値1のインデックスを取得

left = len(lst[0:id_of_one]) #1より左側にある数列の長さ
right = len(lst[id_of_one+1:]) #1より右側にある数列の長さ
total = left + right





counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

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

id = lst.index(1)

left = len(lst[0:id])
right = len(lst[id+1:])
mod = max(left%(k-1),right%(k-1))

total = left + right

counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

Submission status: Accepted

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

ans = 1

idx = A.index(1)
cnt = 1
right = idx
left = idx
while True:
  for i in range(1, K):
    right += 1
    if(right < len(A)):  
      A[right] = 1
    else:
      left -= 1
      if(0 <= left):
        A[left] = 1
      else:
        print(cnt)
        exit()
  if(left <= 0 and len(A)-1 <= right):
    print(cnt)
    exit()
  else:
    cnt += 1

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

Submission status: Accepted

Solution code:
#C - Minimization
import math
N,K = map(int, input().split())
A = list(map(int, input().split()))
tmp = 0
# for i in range(N):
#     if A[i] == 1:
#         tmp = i+1
#         break

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 - 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:
# Author: cr4zjh0bp
# Created: Tue Mar 10 14:13:53 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
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()))
num = k
ans = 1
while num < n:
    num += k-1
    ans += 1
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-1)/(k-1)))

Submission status: Accepted

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

for _ in range(N):
  i = i + K - 1
  if i < N:
    count += 1

  else:
    count += 1
    break

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n,k=map(int,input().split())
ans=1
now=k
while now<n:
    
    ans+=1
    now+=k-1
print(ans)

Submission status: Accepted

Solution code:
import math
n, k, *nums = map(int, open(0).read().split())
print(math.ceil((n-k)/(k-1))+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x=(n-k)//(k-1)
y=(n-k)%(k-1)

if y==0:
    print(x+1)
else:
    print(x+2)

Submission status: Accepted

Solution code:

def read_input():
    n, k = map(int, input().split())
    alist = map(int, input().split())

    return n, k, alist


def submit():
    n, k, alist = read_input()

    if k >= n:
        print(1)
        return

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


if __name__ == "__main__":
    submit()

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:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    N -= K
    if N <= 0:
        return 1
    return 1 + (N + K - 2) // (K - 1)

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


ans = 0
while n > 0:
    if n == k:
        ans += 1
        break
    n -= k - 1
    ans += 1

print(ans)

Submission status: Accepted

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



def calculate(n,k):
    counts = 0
    while n > 0:
        if n == k:
            counts += 1
            break
        n = n - (k - 1)
        counts += 1
    return counts
result = calculate(N,K)

print(result)

Submission status: Accepted

Solution code:
x,y = map(int,input().split())

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

if x-y <= 0:
    print(1)
    exit()
else:
    x -= y

if x%(y-1)!=0:
    print(2+x//(y-1))
else:
    print(1+x//(y-1))

Submission status: Accepted

Solution code:

import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd

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)

#mini = min(a)
#mini_index = a.index(mini)
#
#
##if (len(a)-mini_index)%(k-1):ans = (len(a) - mini_index)/(k-1)+1
##else:ans = (len(a) - mini_index)/(k-1)
##
##if ( (mini_index-1)%(k-1)):ans = ans + (mini_index-1)/(k-1)+1
##else:ans = ans + (mini_index-1)/(k-1)
#
#ans = -(-(len(a)-(mini_index+1))//(k-1))
#ans = ans + (-(-(mini_index-1)//(k-1)))
#
##if ((len(a) - mini_index)%(k-1) + (mini_index-1)%(k-1)) <= (k-1):ans = ans -1
#
#print(ans)
#

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    res = 1
    res += ((len(a)-k) + (k-1) - 1)// (k-1)
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

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

amin=min(a)
m=bisect.bisect(a,amin)

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

k1=k-1
#print(m,k1)

if k1==1:
    print(n-1)
else:
    if m==0:
        n2=(n-1)//k1+1
        print(n2)
    elif m==n:
        n2=(n-1)//k1+1
        print(n2)
    else:
        n2=(m-1-1)//k1+1
        n2r=(n2)*k1-(m-1)
        n3=(n-m-1-n2r)//k1+1
#        print("n",n,"m",m,"k1",k1,"n2",n2,"n3",n3)
        print(n2+n3)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(i)

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

ans = 0

tmp = len(A)

while True:
    tmp -= K
    ans += 1
    if tmp <= 0:
        break
    else:
        tmp += 1

print(ans)

Submission status: Accepted

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


indx = a.index(min(a))
i = (indx-1) + (n-indx)

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

Submission status: Accepted

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

ans=1
n-=k

while n>0:
    n-=(k-1)
    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()]
print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
import math

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

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

one = 1
ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

def main():
    n, k = [int(e) for e in input().split()]
    A = [int(e) for e in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N, K_ko = map(int, input().split())
A = input()
ans = math.ceil((N - K_ko) / (K_ko - 1)) + 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:
import math
N, K = 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 = [int(i) for i in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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