LoginSignup
0
0

More than 1 year has passed since last update.

ABC101 C - Minimization から学んだ

Last updated at Posted at 2021-10-08

abc101_1.png
abc101_2.png
abc101_3.png
abc101_4.png

WA がどうしても取れない。
解答を見た。

なるほど、なるほど。ってわかってるのかな?おれ。
ボーっとした後に思い出しながら書いてみた。
なんとか通った。

Minimization.py
N,K = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0

if K >= N:
    print(1)
else:
    for i in range(10**6):
        if K+(K-1)*i >= N:
            print(i+1)
            break

あれから、再チャレンジしたが WA.
再度回答を確認。
今回はちゃんと理解しながら聞き取れた(つもり)

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

num = N-K

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0