結果

問題 No.1097 Remainder Operation
ユーザー t98slidert98slider
提出日時 2021-07-27 02:46:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 457 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 165,212 KB
実行使用メモリ 34,872 KB
最終ジャッジ日時 2023-09-30 00:45:38
合計ジャッジ時間 7,601 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
32,064 KB
testcase_01 AC 7 ms
32,080 KB
testcase_02 AC 7 ms
32,080 KB
testcase_03 AC 8 ms
32,092 KB
testcase_04 AC 8 ms
32,024 KB
testcase_05 AC 7 ms
32,036 KB
testcase_06 AC 7 ms
32,040 KB
testcase_07 AC 36 ms
32,400 KB
testcase_08 AC 36 ms
32,316 KB
testcase_09 AC 35 ms
32,396 KB
testcase_10 AC 37 ms
32,264 KB
testcase_11 AC 36 ms
32,304 KB
testcase_12 AC 318 ms
34,600 KB
testcase_13 AC 322 ms
34,648 KB
testcase_14 AC 339 ms
34,872 KB
testcase_15 AC 366 ms
34,600 KB
testcase_16 AC 321 ms
34,800 KB
testcase_17 AC 291 ms
34,604 KB
testcase_18 AC 275 ms
34,796 KB
testcase_19 AC 309 ms
34,664 KB
testcase_20 AC 311 ms
34,648 KB
testcase_21 AC 410 ms
34,664 KB
testcase_22 AC 401 ms
34,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

long dp[40][100000],k,ans;

int main(){
    int n,t,i;
    cin>>n;
    for(int i=0;i<n;i++)cin>>dp[0][i];
    for(int i=1;i<40;i++){
        for(int j=0;j<n;j++){
            dp[i][j]=dp[i-1][j]+dp[i-1][(dp[i-1][j]+j)%n];
        }
    }
    cin>>t;
    while(t--){
        cin>>k;
        ans=0;
        for(int i=0;i<40;i++){
            if(k>>i&1)ans+=dp[i][ans%n];
        }
        cout<<ans<<endl;
    }
}
0