結果

問題 No.1097 Remainder Operation
ユーザー U SU S
提出日時 2020-06-26 23:05:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 201,464 KB
最終ジャッジ日時 2023-09-18 07:21:16
合計ジャッジ時間 10,477 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,400 KB
testcase_01 AC 73 ms
71,240 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 352 ms
91,112 KB
testcase_18 AC 358 ms
116,916 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
q = int(input())
used = set()
x = 0
ans = []
x_ans = [0]
while True:
    tar = x % n
    x += a[tar]
    if tar not in used:
        used.add(tar)
        ans.append(tar)
        x_ans.append(x)
    else:
        t = tar
        break
ind_t = ans.index(t)
dif = x_ans[-1] - x_ans[ind_t]
dif_array = x_ans[ind_t+1:]
for i in range(len(dif_array)):
    dif_array[i] -= dif
st = x_ans[ind_t]
for i in range(q):
    k = int(input())
    if k <= n:
        print(x_ans[k])
    else:
        k -= ind_t
        loop = k//len(dif_array)
        mod = k % len(dif_array)
        print(st + loop*dif + sum(dif_array[:mod]))




0