結果
問題 |
No.1097 Remainder Operation
|
ユーザー |
![]() |
提出日時 | 2020-09-25 03:47:53 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 107,904 KB |
最終ジャッジ日時 | 2024-06-28 05:41:52 |
合計ジャッジ時間 | 4,817 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
import sys import io, os input = sys.stdin.buffer.readline #input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n = int(input()) A = list(map(int, input().split())) X = [0]*(n+2) used = {} x = 0 X[0] = x for i in range(n+1): r = x%n x += A[r] X[i+1] = x if r in used: c = i-used[r] t = used[r] break else: used[r] = i cum = X[t:t+c+1] s = cum[-1]-cum[0] Q = int(input()) for i in range(Q): k = int(input()) if k < t: print(X[k]) else: q, r = divmod(k-t, c) ans = X[t]+s*q+cum[r]-cum[0] print(ans)