結果
| 問題 |
No.1097 Remainder Operation
|
| コンテスト | |
| ユーザー |
Dente
|
| 提出日時 | 2020-06-26 23:19:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 483 ms / 2,000 ms |
| コード長 | 869 bytes |
| コンパイル時間 | 1,931 ms |
| コンパイル使用メモリ | 194,228 KB |
| 最終ジャッジ日時 | 2025-01-11 12:12:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
signed main() {
int n;
cin >> n;
int a[n];
rep(i, n) {
cin >> a[i];
}
int q;
cin >> q;
ll k[q];
rep(i, q) {
cin >> k[i];
}
ll dp[60 + 1][n];
rep(i, n) {
dp[0][i] = a[i];
}
for (int i = 0; i < 60; i++) {
for (int j = 0; j < n; j++) {
dp[i + 1][j] = dp[i][(dp[i][j] + j) % n] + dp[i][j];
}
}
rep(i, q) {
ll ans = 0;
for (int j = 0; j < 60; j++) {
if (k[i] & (1LL << j)) ans += dp[j][ans % n];
}
cout << ans << endl;
}
return 0;
}
Dente