結果
| 問題 |
No.1097 Remainder Operation
|
| コンテスト | |
| ユーザー |
fastmath
|
| 提出日時 | 2020-06-26 22:57:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 2,000 ms |
| コード長 | 1,105 bytes |
| コンパイル時間 | 1,587 ms |
| コンパイル使用メモリ | 168,304 KB |
| 実行使用メモリ | 43,136 KB |
| 最終ジャッジ日時 | 2024-07-04 23:11:46 |
| 合計ジャッジ時間 | 5,540 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5+7, LG = 50;
int dp[LG][N];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
#define endl '\n'
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
dp[0][i] = a[i];
}
for (int p = 1; p < LG; ++p) {
for (int i = 0; i < n; ++i) {
int mid = (i+dp[p-1][i])%n;
dp[p][i] = dp[p-1][i]+dp[p-1][mid];
}
}
int q;
cin >> q;
while (q--) {
int k;
cin >> k;
int ans = 0;
for (int p = 0; p < LG; ++p) {
if ((k >> p) & 1) {
ans += dp[p][ans%n];
}
}
cout << ans << endl;
}
}
fastmath