結果

問題 No.1097 Remainder Operation
ユーザー ttrttr
提出日時 2020-06-26 22:54:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 660 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 94,656 KB
最終ジャッジ日時 2023-09-18 06:55:42
合計ジャッジ時間 7,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,444 KB
testcase_01 AC 73 ms
71,344 KB
testcase_02 AC 75 ms
71,648 KB
testcase_03 AC 74 ms
71,376 KB
testcase_04 AC 76 ms
71,636 KB
testcase_05 AC 75 ms
71,444 KB
testcase_06 AC 76 ms
71,616 KB
testcase_07 AC 133 ms
79,512 KB
testcase_08 AC 134 ms
79,828 KB
testcase_09 AC 134 ms
79,432 KB
testcase_10 AC 134 ms
79,228 KB
testcase_11 AC 136 ms
79,556 KB
testcase_12 AC 346 ms
93,716 KB
testcase_13 AC 360 ms
93,664 KB
testcase_14 AC 340 ms
93,528 KB
testcase_15 AC 349 ms
93,740 KB
testcase_16 AC 348 ms
93,704 KB
testcase_17 AC 352 ms
93,500 KB
testcase_18 AC 340 ms
94,512 KB
testcase_19 AC 345 ms
94,656 KB
testcase_20 AC 355 ms
94,528 KB
testcase_21 AC 346 ms
94,540 KB
testcase_22 AC 353 ms
94,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = [int(a) for a in input().split()]

L = [[-1, -1] for _ in range(N)]
X = 0
i = 0
cnt = 0
num = [0]*(N+1)
while L[i][0] < 0:
    cnt += 1
    X += A[i]
    num[cnt] = X
    L[i][0] = X
    L[i][1] = cnt
    i = X%N

t0 = L[i][1]
p0 = L[i][0]
t = cnt-L[i][1]+1
p = X-L[i][0]+A[i]
Q = int(input())
for _ in range(Q):
    K = int(input())
    if K <= t0:
        print(num[K])
    else:
        K -= t0
        print((K//t)*p+num[K%t+t0])
0