結果

問題 No.1097 Remainder Operation
ユーザー mkawa2mkawa2
提出日時 2021-06-16 23:09:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,258 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 11,028 KB
実行使用メモリ 247,388 KB
最終ジャッジ日時 2023-08-30 04:34:18
合計ジャッジ時間 9,153 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,536 KB
testcase_01 AC 17 ms
8,100 KB
testcase_02 AC 20 ms
8,080 KB
testcase_03 AC 20 ms
8,060 KB
testcase_04 AC 20 ms
8,076 KB
testcase_05 AC 19 ms
8,076 KB
testcase_06 AC 20 ms
8,132 KB
testcase_07 AC 418 ms
31,856 KB
testcase_08 AC 415 ms
31,880 KB
testcase_09 AC 417 ms
31,932 KB
testcase_10 AC 412 ms
31,768 KB
testcase_11 AC 428 ms
31,808 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

mx = 10**12
maxlv = mx.bit_length()

n = II()
aa = LI()
to = [[-1]*n for _ in range(maxlv)]
cost = [[0]*n for _ in range(maxlv)]
for i, a in enumerate(aa):
    to[0][i] = (i+a)%n
    cost[0][i] = a

for lv in range(maxlv-1):
    for j in range(n):
        j0 = to[lv][j]
        j1 = to[lv][j0]
        to[lv+1][j] = j1
        cost[lv+1][j] = cost[lv][j]+cost[lv][j0]

for _ in range(II()):
    k = II()
    ans = 0
    j = 0
    for lv in range(maxlv):
        if k >> lv & 1:
            ans += cost[lv][j]
            j = to[lv][j]
    print(ans)
0