結果

問題 No.1097 Remainder Operation
ユーザー DenteDente
提出日時 2020-06-26 23:14:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 199,240 KB
実行使用メモリ 52,288 KB
最終ジャッジ日時 2023-09-18 07:42:54
合計ジャッジ時間 8,269 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 311 ms
52,192 KB
testcase_18 AC 292 ms
52,264 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

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][cur];
                cur = dp[j][cur] % n;
            }
        }
        cout << ans << endl;
    }
    return 0;
}
0