結果
問題 | No.1097 Remainder Operation |
ユーザー |
![]() |
提出日時 | 2020-12-15 23:29:37 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 328 ms / 2,000 ms |
コード長 | 772 bytes |
コンパイル時間 | 91 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 21,728 KB |
最終ジャッジ日時 | 2024-09-20 02:27:44 |
合計ジャッジ時間 | 6,316 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
from itertools import accumulateimport sysinput = sys.stdin.buffer.readlinesys.setrecursionlimit(10 ** 7)N = int(input())A = list(map(int, input().split()))seen = [0] * Nfirst = [0]second = [0]x = 0while True:i = x % Nif seen[i] == 0:first.append(A[i])x += A[i]seen[i] = 1elif seen[i] == 1:second.append(A[i])x += A[i]seen[i] = 2elif seen[i] >= 2:breakF = list(accumulate(first))S = list(accumulate(second))LF = len(F) - 1LS = len(S) - 1def cnt(k):if k <= LF:return F[k]res = F[LF]k -= LFd, m = divmod(k, LS)res += d * S[LS]res += S[m]return resQ = int(input())for _ in range(Q):k = int(input())print(cnt(k))