結果
問題 | No.1097 Remainder Operation |
ユーザー | U S |
提出日時 | 2020-06-26 23:11:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 725 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 86,984 KB |
実行使用メモリ | 201,856 KB |
最終ジャッジ日時 | 2023-09-18 07:34:54 |
合計ジャッジ時間 | 10,147 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
75,656 KB |
testcase_01 | AC | 73 ms
71,148 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 | 344 ms
90,784 KB |
testcase_18 | AC | 368 ms
116,904 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | TLE | - |
testcase_22 | -- | - |
ソースコード
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] if ind_t == len(ans)-1: dif_array = [0] else: 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]))