結果

問題 No.1097 Remainder Operation
ユーザー fastmathfastmath
提出日時 2020-06-26 22:57:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 1,741 ms
コンパイル使用メモリ 166,192 KB
実行使用メモリ 43,028 KB
最終ジャッジ日時 2023-09-18 07:00:33
合計ジャッジ時間 5,944 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
40,280 KB
testcase_01 AC 9 ms
40,192 KB
testcase_02 AC 9 ms
40,312 KB
testcase_03 AC 9 ms
40,336 KB
testcase_04 AC 9 ms
40,212 KB
testcase_05 AC 9 ms
40,324 KB
testcase_06 AC 9 ms
40,300 KB
testcase_07 AC 21 ms
40,496 KB
testcase_08 AC 22 ms
40,500 KB
testcase_09 AC 21 ms
40,636 KB
testcase_10 AC 21 ms
40,536 KB
testcase_11 AC 21 ms
40,556 KB
testcase_12 AC 153 ms
43,028 KB
testcase_13 AC 161 ms
42,960 KB
testcase_14 AC 166 ms
42,940 KB
testcase_15 AC 177 ms
42,864 KB
testcase_16 AC 156 ms
42,956 KB
testcase_17 AC 118 ms
42,960 KB
testcase_18 AC 114 ms
42,956 KB
testcase_19 AC 151 ms
42,864 KB
testcase_20 AC 149 ms
42,872 KB
testcase_21 AC 247 ms
42,876 KB
testcase_22 AC 247 ms
42,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 1e5+7, LG = 50;
int dp[LG][N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        dp[0][i] = a[i];
    }   

    for (int p = 1; p < LG; ++p) {
        for (int i = 0; i < n; ++i) {
            int mid = (i+dp[p-1][i])%n;
            dp[p][i] = dp[p-1][i]+dp[p-1][mid];
        }   
    }   

    int q;
    cin >> q;

    while (q--) {
        int k;
        cin >> k;
        int ans = 0;
        for (int p = 0; p < LG; ++p) {
            if ((k >> p) & 1) {
                ans += dp[p][ans%n];
            }   
        }   
        cout << ans << endl;
    }   
}
0