結果

問題 No.1097 Remainder Operation
ユーザー DenteDente
提出日時 2020-06-26 23:18:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 404 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 198,712 KB
実行使用メモリ 52,284 KB
最終ジャッジ日時 2023-09-18 07:56:42
合計ジャッジ時間 8,135 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 34 ms
8,172 KB
testcase_08 AC 34 ms
8,148 KB
testcase_09 AC 33 ms
8,232 KB
testcase_10 AC 33 ms
8,152 KB
testcase_11 AC 33 ms
8,128 KB
testcase_12 AC 343 ms
52,172 KB
testcase_13 AC 349 ms
52,148 KB
testcase_14 AC 359 ms
52,284 KB
testcase_15 AC 366 ms
52,116 KB
testcase_16 AC 353 ms
52,140 KB
testcase_17 AC 316 ms
52,140 KB
testcase_18 AC 294 ms
52,080 KB
testcase_19 AC 331 ms
52,196 KB
testcase_20 AC 328 ms
52,164 KB
testcase_21 AC 404 ms
52,072 KB
testcase_22 AC 384 ms
52,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    ll k[q];
    rep(i, q) {
        cin >> k[i];
    }
    ll dp[60 + 1][n];
    rep(i, n) {
        dp[0][i] = a[i];
    }
    for (int i = 0; i < 60; i++) {
        for (int j = 0; j < n; j++) {
            dp[i + 1][j] = dp[i][(dp[i][j] + j) % n] + dp[i][j];
        }
    }
    rep(i, q) {
        ll ans = 0;
        int cur = 0;
        for (int j = 0; j < 60; j++) {
            if (k[i] & (1LL << j)) {
                ans += dp[j][ans % n];
            }
        }
        cout << ans << endl;
    }
    return 0;
}
0