結果
問題 | No.1097 Remainder Operation |
ユーザー |
👑 |
提出日時 | 2022-04-17 17:33:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 818 ms / 2,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 153,472 KB |
最終ジャッジ日時 | 2024-12-26 11:15:20 |
合計ジャッジ時間 | 13,300 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
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 % ntot[0][i] = afor i in range(1, 40):for j in range(n):d = nex[i - 1][j]nj = (j + d) % nnex[i][j] = (nex[i - 1][j] + nex[i - 1][nj]) % ntot[i][j] = tot[i - 1][j] + tot[i - 1][nj]Q = int(input())for _ in range(Q):k = int(input())j = 0ans = 0for i in range(40):if k >> i & 1:ans += tot[i][j]j += nex[i][j]j %= nprint(ans)