ABC220 C - Long Sequence を解いた
6579 ワード
一応、以下で通った。
LongSequence.py
from sys import exit
N = int(input())
A = list(map(int,input().split()))
X = int(input())
B = sum(A)
base = X//B
rest = X%B
if rest == 0:
print(base*N+1)#<= ココ1
exit()
else:
cnt = 0
ans = 0
for i in range(N):
cnt += A[i]
if cnt > rest:#<=ココ2
ans = i+1
break
print(base*N+ans)
問題文には 超えるのは何項目?っと聞いている。
最初はココ1 and ココ2 を見逃していて、以下のような記述でWAだった。
LongSequence.py
from sys import exit
N = int(input())
A = list(map(int,input().split()))
X = int(input())
B = sum(A)
base = X//B
rest = X%B
if rest == 0:
print(base*N)#<= ココ1
exit()
else:
cnt = 0
ans = 0
for i in range(N):
cnt += A[i]
if cnt >= rest:#<=ココ2
ans = i+1
break
print(base*N+ans)
シャキッと一発で通せるようになりたい。。
Author And Source
この問題について(ABC220 C - Long Sequence を解いた), 我々は、より多くの情報をここで見つけました https://qiita.com/AKpirion/items/178729439e4faa7fbe82著者帰属:元の著者の情報は、元の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 .