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

ans = 0 - -(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()]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()))
x=a.index(1)
#print(x)

if n==k:
    print(1)
else:
    #if x<=k-1 or x>=n-k:
    if (n-k)%(k-1)==0:
        ans=1+(n-k)//(k-1)
    else:
        ans=1+(n-k)//(k-1)+1


    print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, k = map(int, readline().split())
    print((((n-k)+(k-1)-1)//(k-1))+1)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from bisect import bisect_left

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

pos = bisect_left(a, 1)
print((pos + k - 2) // (k - 1) + (n - pos + k - 3) // (k - 1))

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
A = list(input().split())
A_lis = [int(A[i]) for i in range(N)]
index = A_lis.index(1)

if N == K:
    print(1)
else:
    left = math.ceil(index / (K-1))
    leftamari = index % (K-1)
    right = math.ceil(max(0, N - 1 - index - (K - 1 - leftamari if leftamari != 0 else 0)) / (K-1))
    print(left + right)

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
s = list(map(int, input().split()))
n=s[0]
k=s[1]-1
s = list(map(int, input().split()))
ind=s.index(1)
# print(ind,n-ind-1,math.ceil(ind/k),math.ceil((n-ind-1)/k))
print(math.ceil((n-1)/(k)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
AN = list(map(int,input().split()))
AN.sort()
N = N - AN.count(AN[0])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#
def main():
    n, k = MII()
    aa = MII()
    print((-(-(n-1)//(k-1))) if n > 3 else 1)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 1の場所を探す
pos = A.index(1)

count = 0
num_forward = pos  # 前方の残り数
num_backward = N - pos - 1  # 後方の残り数

# 前方にX回試行したときに負の余りが生じる場合は後方に回す
rest = num_forward % -(K - 1)
num_backward += rest

while num_forward > 0:  # 先頭まで1にする
    num_forward -= K - 1
    count += 1
while num_backward > 0:  # 末尾まで1にする
    num_backward -= K - 1
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

if tmp%(K - 1) != 0:
    ans += 1

print(ans)

Submission status: Accepted

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

if m % l == 0:
    print(m // l)
else:
    print(m // l + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
now=0
ans=0
if n==k:
  print(1)
else:
  while(True):
    n-=k
    ans+=1
    if n<=0:
      break
    else:
      n+=1
      
  print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = lr()
answer = -(-(N-1)//(K-1))
print(answer)

Submission status: Accepted

Solution code:

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


N -= K

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

Submission status: Accepted

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

for i,v in enumerate(x):
    if v == 1:
        r = i
a,b = divmod(r,k-1)
if b > 0:
    a += 1
r = a * (k-1)

l = n-r-1
if l > 0:
    c,d = divmod(l, k-1)
    if d > 0:
        c += 1
    a += c

print(a)

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#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

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

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

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N, K = getNM()
A = getList()
mi = min(A)
miindex = []
for i in range(N):
    if A[i] == mi:
        miindex.append(i)
ans = 1000000
for i in miindex:
    rang = K - 1
    opt1 = (i + rang - 1) // rang
    newi = opt1 * rang + 1
    opt2 = ((N - newi) + rang - 1) // rang
    ans = min(ans, opt1 + opt2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
a = nl()

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 == k:
    print(1)
    exit()
import math
print(1 + math.ceil(((n - k) / (k-1))))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

Submission status: Accepted

Solution code:
Len, Split = map(int, input().split())
_res = (Len - 1) % (Split - 1)
if _res:
    res = int(((Len - 1) // (Split - 1)) + 1)
    print(res)
else:
    res = int((Len - 1) // (Split - 1))
    print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1

#############
# Main Code #
#############

N,K = IL()
A = IL()
p = A.index(1)

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

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

def main():
    n, k = read_ints()
    print(math.ceil((n - 1) / (k - 1)))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
an = list(map(int, input().split()))
mini = min(an)
need = 0
for a in an:
    if a != mini:
        need += 1
print(-(-need//(k-1)))

Submission status: Accepted

Solution code:
import math

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

s.sort()
s.remove(s[0])

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
# def resolve():
# 	n, k = map(int, input().split())
# 	a = list(map(int, input().split()))
# 	i = a.index(min(a)) + 1
# 	if k - 1 > i:
# 		v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1
# 	else:
# 		v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1))
# 	print(v)

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

Submission status: Accepted

Solution code:
import math
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a)) + 1
	if k - 1 > i:
		v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1
	else:
		v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1))
	print(v)
resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, k = Is()
A = LI()
ans = 1
tmp = n - k
if tmp > 0:
    ans += ceil(tmp/(k-1))
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))
######################################################################################################
def main():
    N,K=inputintlist()
    A=inputintlist()
    N-=1
    K-=1
    ans=(N+K-1)//K
    print(ans)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    index_one = A.index(1)
    min_cnt = N
    for left_index in range(index_one - (K - 1), index_one + 1):
        right_index = left_index + (K - 1)
        if left_index < 0 or right_index > N - 1:
            continue
        cnt = 1 + math.ceil(left_index / (K - 1)) + math.ceil((N - 1 - right_index) / (K - 1))
        min_cnt = min([min_cnt, cnt])
    print(min_cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
for i in range(n):
    if lis[i]==1:
        one=i+1
#print(one)
ans=ceil((n-1)/(k-1))
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = input()
i = s.find("1")/2
ans = 0

# former part
while ans * (k-1) < i:
    ans += 1
i = max(i, ans * (k-1))

# latter part
tmp = 0
while tmp * (k-1) + i < n-1:
    tmp += 1

print(ans + tmp)

Submission status: Accepted

Solution code:
from math import ceil
n, k = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]
print(ceil((n - 1) / (k - 1)))

Submission status: Accepted

Solution code:
import math

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

n = max(0, N - K)
print(1 + math.ceil(n / (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 = (int(x) for x in 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:
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()))

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

Submission status: Accepted

Solution code:
from math import ceil

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

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

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

Submission status: Accepted

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

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

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

if least_g.is_integer():
    print(int(least_g))
else:
    print(int(least_g)+1)

Submission status: Accepted

Solution code:
input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))

Submission status: Accepted

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

resolve()

Submission status: Accepted

Solution code:
def main():
  n, k = map(int, input().split())
  m = 1 + (n - k) // (k - 1)
  if (n - k) % (k - 1) == 0:
    print(m)
  else:
    print(m + 1)
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
def main():
  n, k = map(int, input().split())
  if (n - k) % (k - 1):
    print(1 + (n - k) // (k - 1) + 1)
  else:
    print(1 + (n - k) // (k - 1) )
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
def main():
  n, k = map(int, input().split())
  if (n - k) % (k - 1) == 0:
    print(1 + (n - k) // (k - 1))
  else:
    print(1 + (n - k) // (k - 1) + 1)
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
n, k = 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());print(1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0))

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, k, *a = map(int, open(0).read().split())
    ans = 1 + (n - k) // (k - 1) + ((n - k) % (k - 1) != 0)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    from math import ceil
    n, k, *a = map(int, open(0).read().split())
    i = a.index(1)
    ans = 1 + ceil((n - k) / (k - 1))
    print(ans)


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