ABC106 C - To Infinity から学んだ
4235 ワード
訳が分からず、回答を確認
訳が分かっていなかったのは自分だった。
つまり問題を誤って認識していた。
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 で解けて良かった。
Author And Source
この問題について(ABC106 C - To Infinity から学んだ), 我々は、より多くの情報をここで見つけました https://qiita.com/AKpirion/items/9c5732f338a3255d4ef0著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .