結果

問題 No.1097 Remainder Operation
ユーザー tamatotamato
提出日時 2020-12-22 18:37:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 120,864 KB
最終ジャッジ日時 2023-10-21 13:00:51
合計ジャッジ時間 8,879 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,516 KB
testcase_01 AC 38 ms
53,516 KB
testcase_02 AC 46 ms
59,552 KB
testcase_03 AC 46 ms
59,552 KB
testcase_04 AC 45 ms
59,552 KB
testcase_05 AC 45 ms
59,552 KB
testcase_06 AC 46 ms
59,552 KB
testcase_07 AC 75 ms
73,156 KB
testcase_08 AC 83 ms
79,128 KB
testcase_09 AC 76 ms
73,168 KB
testcase_10 AC 76 ms
73,160 KB
testcase_11 AC 77 ms
73,184 KB
testcase_12 AC 338 ms
120,816 KB
testcase_13 AC 364 ms
120,816 KB
testcase_14 AC 376 ms
120,816 KB
testcase_15 AC 411 ms
120,756 KB
testcase_16 AC 355 ms
120,816 KB
testcase_17 AC 270 ms
120,864 KB
testcase_18 AC 257 ms
120,272 KB
testcase_19 AC 332 ms
120,272 KB
testcase_20 AC 330 ms
120,332 KB
testcase_21 AC 439 ms
120,272 KB
testcase_22 AC 442 ms
120,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    A = list(map(int, input().split()))

    nxt = [[0] * N for _ in range(41)]
    for i in range(N):
        nxt[0][i] = A[i]
    for lv in range(1, 41):
        for i in range(N):
            tmp = nxt[lv-1][i]
            j = (i + tmp)%N
            nxt[lv][i] = tmp + nxt[lv-1][j]

    for _ in range(int(input())):
        k = int(input())
        i = 0
        ans = 0
        for lv in range(41):
            if k >> lv & 1:
                tmp = nxt[lv][i]
                ans += tmp
                i = (i + tmp)%N
        print(ans)


if __name__ == '__main__':
    main()
0