結果

問題 No.1097 Remainder Operation
ユーザー 沙耶花沙耶花
提出日時 2020-05-24 21:26:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 621 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 2,860 ms
コンパイル使用メモリ 204,808 KB
実行使用メモリ 38,932 KB
最終ジャッジ日時 2023-08-14 17:10:02
合計ジャッジ時間 9,443 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 37 ms
6,852 KB
testcase_08 AC 37 ms
6,692 KB
testcase_09 AC 36 ms
6,648 KB
testcase_10 AC 37 ms
6,724 KB
testcase_11 AC 36 ms
6,612 KB
testcase_12 AC 435 ms
38,808 KB
testcase_13 AC 423 ms
38,680 KB
testcase_14 AC 432 ms
38,688 KB
testcase_15 AC 455 ms
38,740 KB
testcase_16 AC 438 ms
38,616 KB
testcase_17 AC 391 ms
38,616 KB
testcase_18 AC 374 ms
38,640 KB
testcase_19 AC 461 ms
38,636 KB
testcase_20 AC 456 ms
38,932 KB
testcase_21 AC 621 ms
38,616 KB
testcase_22 AC 607 ms
38,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	vector<vector<long long>> doubling(N,vector<long long>(40,0LL));
	
	for(int i=0;i<40;i++){
		for(int j=0;j<N;j++){
			if(i==0){
				doubling[j][i] = A[j];
			}
			else{
				doubling[j][i] = doubling[j][i-1] + doubling[((doubling[j][i-1]+j)%N)][i-1];
			}
		}
	}
	
	int Q;
	cin>>Q;
	
	for(int i=0;i<Q;i++){
		long long K;
		cin>>K;
		
		long long ans = 0;
		for(int j=0;j<40;j++){
			if((K>>j)&1){
				ans += doubling[ans%N][j];
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}
0