結果
| 問題 | 
                            No.1097 Remainder Operation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-26 22:25:06 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 867 bytes | 
| コンパイル時間 | 1,505 ms | 
| コンパイル使用メモリ | 172,576 KB | 
| 実行使用メモリ | 13,752 KB | 
| 最終ジャッジ日時 | 2024-07-04 22:08:20 | 
| 合計ジャッジ時間 | 5,314 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | WA * 5 TLE * 1 -- * 15 | 
ソースコード
#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;
    while(k>0){
      if(k%2==1){
        ans += add[0];
      }
      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;
}