結果

問題 No.1097 Remainder Operation
ユーザー NewGardenNewGarden
提出日時 2020-06-26 22:28:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 911 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 169,572 KB
実行使用メモリ 8,032 KB
最終ジャッジ日時 2023-09-18 05:52:49
合計ジャッジ時間 6,623 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  vector<int> ido(n);
  rep(i,n){
    ido[i] = (i+a[i])%n;
  }
  int q; cin >> q;
  while(q--){
    ll k; cin >> k;
    auto nxt = ido;
    auto add = a;
    ll ans = 0;
    int pos = 0;
    while(k>0){
      if(k%2==1){
        ans += add[pos];
        pos = nxt[pos];
      }
      auto nx = nxt;
      auto ad = add;
      rep(i,n){
        nxt[i] = nx[nx[i]];
        add[i] = ad[i] + ad[nx[i]];
      }
      k/=2;
    }
    cout << ans << ln;
  }  

  return 0;
}
0