結果
| 問題 |
No.1097 Remainder Operation
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2020-12-15 23:26:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 776 bytes |
| コンパイル時間 | 77 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 21,592 KB |
| 最終ジャッジ日時 | 2024-09-20 02:27:13 |
| 合計ジャッジ時間 | 5,326 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 RE * 1 |
ソースコード
from itertools import accumulate
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
A = list(map(int, input().split()))
seen = [0] * N
first = [0]
second = [0]
x = 0
while True:
i = x % N
if seen[i] == 0:
first.append(A[i])
x += A[i]
seen[i] = 1
elif seen[i] == 1:
second.append(A[i])
x += A[i]
seen[i] = 2
elif seen[i] >= 2:
break
F = list(accumulate(first))
S = list(accumulate(second))
LF = len(F) - 1
LS = len(S) - 1
def cnt(k):
if k <= len(F):
return F[k]
res = F[LF]
k -= LF
d, m = divmod(k, LS)
res += d * S[LS]
res += S[m]
return res
Q = int(input())
for _ in range(Q):
k = int(input())
print(cnt(k))
tktk_snsn