結果

問題 No.1097 Remainder Operation
ユーザー yuruhiyayuruhiya
提出日時 2020-08-06 09:35:54
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 344 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 11,948 KB
実行使用メモリ 84,476 KB
最終ジャッジ日時 2023-10-19 11:38:06
合計ジャッジ時間 26,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
16,016 KB
testcase_01 AC 85 ms
16,016 KB
testcase_02 AC 88 ms
16,016 KB
testcase_03 AC 89 ms
16,016 KB
testcase_04 AC 91 ms
16,016 KB
testcase_05 AC 90 ms
16,016 KB
testcase_06 AC 89 ms
16,016 KB
testcase_07 AC 273 ms
22,392 KB
testcase_08 AC 276 ms
22,392 KB
testcase_09 AC 275 ms
22,392 KB
testcase_10 AC 273 ms
22,392 KB
testcase_11 AC 275 ms
22,392 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 AC 1,951 ms
84,464 KB
testcase_18 AC 1,952 ms
83,876 KB
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map &:to_i
b = Array.new(40) { [0] * n }
b.each_index do |i|
	b[i] =
		(
			if i == 0
				a
			else
				b[i - 1].map.with_index { |v, j| v + b[i - 1][(v + j) % n] }
			end
		)
end

gets.to_i.times do
	k = gets.to_i
	puts b.each_with_index.reduce(0) { |acc, (v, i)|
			acc + (k[i] == 1 ? v[acc % n] : 0)
	     }
end
0