結果
| 問題 |
No.1097 Remainder Operation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-26 21:52:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 273 ms / 2,000 ms |
| コード長 | 861 bytes |
| コンパイル時間 | 912 ms |
| コンパイル使用メモリ | 80,952 KB |
| 最終ジャッジ日時 | 2025-01-11 11:19:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long int ll;
int to[50][100100];
ll sum[50][100100];
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n; cin >> n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
to[0][i]=(i+a[i])%n;
sum[0][i]=a[i];
}
for(int i=0;i<49;i++){
for(int j=0;j<n;j++){
to[i+1][j]=to[i][to[i][j]];
sum[i+1][j]=sum[i][j]+sum[i][to[i][j]];
}
}
int q; cin >> q;
while(q--){
ll k; cin >> k;
int now=0;
ll res=0;
for(int i=49;i>=0;i--){
if((k>>i)&1){
res+=sum[i][now];
now=to[i][now];
}
}
cout << res << endl;
}
}