結果
問題 |
No.1097 Remainder Operation
|
ユーザー |
|
提出日時 | 2020-09-01 19:31:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 389 ms / 2,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 2,021 ms |
コンパイル使用メモリ | 193,044 KB |
最終ジャッジ日時 | 2025-01-14 03:07:08 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int n; int a[100000]; long long dp[50][100000]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; REP (i, n) cin >> a[i]; REP (i, n) dp[0][i] = a[i]; for (int j = 1; j < 50; j++) { for (int i = 0; i < n; i++) dp[j][i] = dp[j-1][i] + dp[j-1][(i + dp[j-1][i]) % n]; // i: current state of x, j: log(length) } int q; cin >> q; REP (_, q) { long long k; cin >> k; long long x = 0; REP (i, 50) { if (k & 1LL<<i) { x += dp[i][x%n]; } } cout << x << endl; } return 0; }