結果
問題 | No.1097 Remainder Operation |
ユーザー |
|
提出日時 | 2020-06-26 22:31:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 205 ms / 2,000 ms |
コード長 | 1,129 bytes |
コンパイル時間 | 864 ms |
コンパイル使用メモリ | 90,740 KB |
実行使用メモリ | 75,204 KB |
最終ジャッジ日時 | 2024-07-04 22:16:16 |
合計ジャッジ時間 | 4,540 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include<iostream>#include<string>#include<iomanip>#include<cmath>#include<vector>#include<algorithm>#include<utility>using namespace std;#define int long long#define endl "\n"constexpr long long INF = (long long)1e18;constexpr long long MOD = 1'000'000'007;struct fast_io {fast_io(){std::cin.tie(nullptr);std::ios::sync_with_stdio(false);};} fio;signed main(){cout<<fixed<<setprecision(10);int N, Q;vector<int> A;vector<vector<int>> table, table2;cin>>N;A.resize(N);table.resize(45, vector<int>(N));table2.resize(45, vector<int>(N));for(int i = 0; i < N; i++){cin>>A[i];table[0][i] = (A[i] + i)% N;table2[0][i] = A[i];}for(int i = 1; i < table.size(); i++){for(int j = 0; j < N; j++){table[i][j] = table[i-1][table[i-1][j]];table2[i][j] = table2[i-1][table[i-1][j]] + table2[i-1][j];}}cin>>Q;for(int i = 0; i < Q; i++){int K;int res = 0, now = 0;cin>>K;for(int i = 0; i < table.size(); i++){if((K>>i)&1) {res += table2[i][now];now = table[i][now];}}cout<<res<<endl;}return 0;}