結果

問題 No.1097 Remainder Operation
ユーザー iqueue02iqueue02
提出日時 2020-06-26 22:14:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 467 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 203,572 KB
実行使用メモリ 52,300 KB
最終ジャッジ日時 2023-09-18 05:18:41
合計ジャッジ時間 8,419 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 35 ms
7,764 KB
testcase_08 AC 35 ms
7,844 KB
testcase_09 AC 36 ms
7,792 KB
testcase_10 AC 35 ms
7,872 KB
testcase_11 AC 35 ms
7,932 KB
testcase_12 AC 383 ms
52,296 KB
testcase_13 AC 399 ms
52,088 KB
testcase_14 AC 406 ms
52,116 KB
testcase_15 AC 422 ms
52,112 KB
testcase_16 AC 388 ms
52,300 KB
testcase_17 AC 341 ms
52,292 KB
testcase_18 AC 319 ms
52,268 KB
testcase_19 AC 360 ms
52,296 KB
testcase_20 AC 359 ms
52,164 KB
testcase_21 AC 467 ms
52,160 KB
testcase_22 AC 464 ms
52,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr ll INF = (1LL << 60);

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<vector<ll>> to(61, vector<ll>(n, 0));

  for (int i = 0; i < n; i++) to[0][i] = a[i];

  for (int i = 0; i < 60; i++) {
    for (int j = 0; j < n; j++) to[i + 1][j] = to[i][j] + to[i][(j + to[i][j]) % n];
  }

  int q;
  cin >> q;

  while (q--) {
    ll k;
    cin >> k;
    ll res = 0;
    for (int j = 0; j < 60; j++) {
      if (k & (1LL << j)) res += to[j][res % n];
    }
    cout << res << endl;
  }

  return 0;
} 
0