結果

問題 No.1097 Remainder Operation
ユーザー hiro71687khiro71687k
提出日時 2023-03-08 12:54:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 931 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 4,244 ms
コンパイル使用メモリ 265,076 KB
実行使用メモリ 47,472 KB
最終ジャッジ日時 2023-10-18 05:54:36
合計ジャッジ時間 15,820 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 45 ms
8,284 KB
testcase_08 AC 45 ms
8,284 KB
testcase_09 AC 44 ms
8,284 KB
testcase_10 AC 44 ms
8,284 KB
testcase_11 AC 45 ms
8,284 KB
testcase_12 AC 620 ms
47,472 KB
testcase_13 AC 662 ms
47,472 KB
testcase_14 AC 659 ms
47,472 KB
testcase_15 AC 655 ms
47,472 KB
testcase_16 AC 644 ms
47,472 KB
testcase_17 AC 592 ms
47,472 KB
testcase_18 AC 520 ms
47,472 KB
testcase_19 AC 658 ms
47,472 KB
testcase_20 AC 683 ms
47,472 KB
testcase_21 AC 839 ms
47,472 KB
testcase_22 AC 931 ms
47,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=10010010010010010;
ll mod=17;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll q;
    cin >> q;
    vector<vector<ll>>db(n+1000,vector<ll>(50,0));
    for (ll i = 0; i < n; i++)
    {
        db[i][0]=a[i];
    }
    for (ll i = 1; i < 50; i++)
    {
        for (ll j = 0; j < n; j++)
        {
            db[j][i]=db[((db[j][i-1]+j)%n+n)%n][i-1]+db[j][i-1];
        }
    }
    vector<ll>two(50,1);
    for (ll i = 1; i < 50; i++)
    {
        two[i]=two[i-1]*2;
    }
    for (ll i = 0; i < q; i++)
    {
        ll k;
        cin >> k;
        ll now=0;
        for (ll j = 0; j < 50; j++)
        {
            if (two[j]&k)
            {
                now+=db[now%n][j];
            }
        }
        cout << now << endl;
    }
    
}
0