結果

問題 No.1097 Remainder Operation
ユーザー DenteDente
提出日時 2020-06-26 23:19:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 198,812 KB
実行使用メモリ 52,452 KB
最終ジャッジ日時 2023-09-18 07:58:14
合計ジャッジ時間 8,838 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 34 ms
8,416 KB
testcase_08 AC 34 ms
8,416 KB
testcase_09 AC 34 ms
8,176 KB
testcase_10 AC 33 ms
8,388 KB
testcase_11 AC 34 ms
8,224 KB
testcase_12 AC 347 ms
52,176 KB
testcase_13 AC 352 ms
52,264 KB
testcase_14 AC 354 ms
52,196 KB
testcase_15 AC 367 ms
52,108 KB
testcase_16 AC 349 ms
52,260 KB
testcase_17 AC 318 ms
52,452 KB
testcase_18 AC 295 ms
52,172 KB
testcase_19 AC 328 ms
52,136 KB
testcase_20 AC 328 ms
52,192 KB
testcase_21 AC 390 ms
52,236 KB
testcase_22 AC 398 ms
52,136 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;
        for (int j = 0; j < 60; j++) {
            if (k[i] & (1LL << j)) ans += dp[j][ans % n];
        }
        cout << ans << endl;
    }
    return 0;
}
0