結果
問題 | No.1097 Remainder Operation |
ユーザー | 👑 rin204 |
提出日時 | 2022-04-17 17:33:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 742 ms / 2,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 388 ms |
コンパイル使用メモリ | 87,084 KB |
実行使用メモリ | 155,024 KB |
最終ジャッジ日時 | 2023-08-27 03:46:53 |
合計ジャッジ時間 | 12,640 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
71,396 KB |
testcase_01 | AC | 75 ms
71,268 KB |
testcase_02 | AC | 93 ms
77,028 KB |
testcase_03 | AC | 92 ms
76,992 KB |
testcase_04 | AC | 93 ms
76,884 KB |
testcase_05 | AC | 92 ms
77,036 KB |
testcase_06 | AC | 92 ms
76,980 KB |
testcase_07 | AC | 147 ms
85,000 KB |
testcase_08 | AC | 148 ms
84,640 KB |
testcase_09 | AC | 144 ms
84,876 KB |
testcase_10 | AC | 143 ms
84,640 KB |
testcase_11 | AC | 147 ms
85,036 KB |
testcase_12 | AC | 639 ms
154,888 KB |
testcase_13 | AC | 670 ms
154,628 KB |
testcase_14 | AC | 717 ms
154,696 KB |
testcase_15 | AC | 742 ms
154,540 KB |
testcase_16 | AC | 647 ms
154,840 KB |
testcase_17 | AC | 506 ms
155,024 KB |
testcase_18 | AC | 502 ms
153,528 KB |
testcase_19 | AC | 588 ms
153,836 KB |
testcase_20 | AC | 608 ms
153,840 KB |
testcase_21 | AC | 716 ms
153,468 KB |
testcase_22 | AC | 737 ms
153,692 KB |
ソースコード
n = int(input()) A = list(map(int, input().split())) nex = [[0] * n for _ in range(40)] tot = [[0] * n for _ in range(40)] for i, a in enumerate(A): nex[0][i] = a % n tot[0][i] = a for i in range(1, 40): for j in range(n): d = nex[i - 1][j] nj = (j + d) % n nex[i][j] = (nex[i - 1][j] + nex[i - 1][nj]) % n tot[i][j] = tot[i - 1][j] + tot[i - 1][nj] Q = int(input()) for _ in range(Q): k = int(input()) j = 0 ans = 0 for i in range(40): if k >> i & 1: ans += tot[i][j] j += nex[i][j] j %= n print(ans)