結果

問題 No.1097 Remainder Operation
ユーザー beetbeet
提出日時 2020-06-26 21:30:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 199,812 KB
実行使用メモリ 64,792 KB
最終ジャッジ日時 2023-09-18 03:10:01
合計ジャッジ時間 6,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
54,580 KB
testcase_01 AC 2 ms
4,988 KB
testcase_02 AC 2 ms
5,052 KB
testcase_03 AC 2 ms
5,052 KB
testcase_04 AC 2 ms
5,236 KB
testcase_05 AC 2 ms
4,988 KB
testcase_06 AC 3 ms
4,988 KB
testcase_07 AC 15 ms
6,636 KB
testcase_08 AC 15 ms
6,764 KB
testcase_09 AC 15 ms
6,632 KB
testcase_10 AC 15 ms
6,660 KB
testcase_11 AC 15 ms
6,764 KB
testcase_12 AC 143 ms
64,792 KB
testcase_13 AC 151 ms
64,636 KB
testcase_14 AC 158 ms
64,564 KB
testcase_15 AC 167 ms
64,564 KB
testcase_16 AC 149 ms
64,600 KB
testcase_17 AC 110 ms
64,556 KB
testcase_18 AC 105 ms
64,688 KB
testcase_19 AC 138 ms
64,672 KB
testcase_20 AC 137 ms
64,704 KB
testcase_21 AC 225 ms
64,700 KB
testcase_22 AC 226 ms
64,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const Int LOG = 40;
const Int MAX = 2e5;
Int dp[LOG][MAX]={};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  for(Int i=0;i<n;i++)
    dp[0][i]=as[i];

  for(Int j=0;j+1<LOG;j++)
    for(Int i=0;i<n;i++)
      dp[j+1][i]=dp[j][i]+dp[j][(i+dp[j][i])%n];

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int k;
    cin>>k;

    Int x=0;
    for(Int j=0;j<LOG;j++)
      if((k>>j)&1) x+=dp[j][x%n];
    cout<<x<<newl;
  }

  return 0;
}
0