LoginSignup
0
0

More than 1 year has passed since last update.

ABC106 C - To Infinity から学んだ

Last updated at Posted at 2021-09-30

abc106_1.png
abc106_2.png
abc106_3.png
abc106_4.png

訳が分からず、回答を確認

訳が分かっていなかったのは自分だった。
つまり問題を誤って認識していた。

1211 => 12211 => 122211 と考えていた。
それは違う
1211 => 12211 => 1222211 だ。
恥ずかしさがこみ上げる。結局、ちゃんと声に出して読んでないから失敗した。
次は自惚れず、基本に忠実に声に出して正しく考えよう。

ToInfinity.py
S = list(input())
K = int(input())

for s in S:
    if int(s) == 1:
        K -= 1
        if K == 0:
            print(1)
            exit()
    else:
        print(s)
        exit()

時間を空けて再チャレンジ。

S の中で not "1" の index を見つける。
K 文字目という要求が not "1" index より小さいか、大きいかで答えが決まる気がした。

abc106c.py
S = input()
K = int(input())
ref = 0
for i in range(len(S)):
    if S[i] != "1":
        ref = i
        break

if K < ref+1:
    print("1")
else:
    print(S[ref])

無事 AC. no hint で解けて良かった。

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