結果

問題 No.1097 Remainder Operation
ユーザー cao bicao bi
提出日時 2022-02-28 15:39:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,553 ms / 2,000 ms
コード長 363 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 11,176 KB
実行使用メモリ 53,364 KB
最終ジャッジ日時 2023-09-20 23:22:20
合計ジャッジ時間 21,593 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
46,440 KB
testcase_01 AC 109 ms
46,528 KB
testcase_02 AC 111 ms
46,668 KB
testcase_03 AC 111 ms
46,744 KB
testcase_04 AC 110 ms
46,552 KB
testcase_05 AC 111 ms
46,492 KB
testcase_06 AC 112 ms
46,604 KB
testcase_07 AC 243 ms
46,712 KB
testcase_08 AC 246 ms
47,024 KB
testcase_09 AC 245 ms
46,792 KB
testcase_10 AC 243 ms
46,864 KB
testcase_11 AC 245 ms
46,712 KB
testcase_12 AC 1,424 ms
53,176 KB
testcase_13 AC 1,477 ms
53,096 KB
testcase_14 AC 1,510 ms
53,244 KB
testcase_15 AC 1,553 ms
53,096 KB
testcase_16 AC 1,455 ms
53,312 KB
testcase_17 AC 1,353 ms
53,364 KB
testcase_18 AC 1,343 ms
52,660 KB
testcase_19 AC 1,420 ms
52,708 KB
testcase_20 AC 1,422 ms
52,744 KB
testcase_21 AC 1,519 ms
52,724 KB
testcase_22 AC 1,525 ms
52,636 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)
dp = Array.new(40) { Array.new(100005, 0) }

for i in 0...n
	dp[0][i] = a[i]
end


for i in 0...39
	for j in 0...n
		dp[i + 1][j] = dp[i][j] + dp[i][(j + dp[i][j]) % n]
	end
end

q = gets.to_i
while q > 0
	k = gets.to_i
	ans = 0
	for i in 0...40
		if (k[i] == 1)
			ans += dp[i][ans % n]
		end
	end
	puts ans
	q -= 1
end

0