結果

問題 No.420 mod2漸化式
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-17 14:55:07
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 15,416 KB
最終ジャッジ日時 2023-08-25 15:39:35
合計ジャッジ時間 4,707 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
15,152 KB
testcase_01 AC 75 ms
15,288 KB
testcase_02 AC 74 ms
15,180 KB
testcase_03 AC 72 ms
15,100 KB
testcase_04 AC 75 ms
15,188 KB
testcase_05 AC 74 ms
15,108 KB
testcase_06 WA -
testcase_07 AC 71 ms
15,180 KB
testcase_08 AC 72 ms
15,236 KB
testcase_09 AC 72 ms
15,308 KB
testcase_10 AC 72 ms
15,288 KB
testcase_11 AC 73 ms
15,072 KB
testcase_12 AC 72 ms
15,148 KB
testcase_13 AC 72 ms
15,036 KB
testcase_14 AC 72 ms
15,144 KB
testcase_15 AC 73 ms
15,184 KB
testcase_16 AC 73 ms
15,176 KB
testcase_17 AC 74 ms
15,140 KB
testcase_18 AC 75 ms
15,180 KB
testcase_19 AC 74 ms
15,252 KB
testcase_20 AC 76 ms
15,100 KB
testcase_21 AC 79 ms
15,144 KB
testcase_22 AC 79 ms
15,100 KB
testcase_23 AC 74 ms
15,256 KB
testcase_24 AC 75 ms
15,416 KB
testcase_25 AC 75 ms
15,044 KB
testcase_26 AC 75 ms
15,308 KB
testcase_27 AC 72 ms
15,332 KB
testcase_28 AC 76 ms
15,200 KB
testcase_29 AC 73 ms
15,104 KB
testcase_30 AC 75 ms
15,300 KB
testcase_31 AC 73 ms
15,148 KB
testcase_32 AC 77 ms
15,180 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
if n==0
	puts 0
elsif n>31
	puts 0
else
	dp = Array.new(31).map{Array.new(31,0)}
	dp2= Array.new(31).map{Array.new(31,0)}
	ans=0
	r=1
	31.times{|i|
		dp[0][i]=1
		dp2[0][i]=r
		ans+=r
		r*=2
	}
	if n==1
		puts [31 ,ans]*" "
	else
		(n-1).times{|p1|
			r=1
			31.times{|p2|
				r2=r*2
				((p2+1)..(30)).each{|p3|
					dp[p1+1][p3]+=dp[p1][p2]
					dp2[p1+1][p3]+=dp[p1][p2]*r2+dp2[p1][p2]
					r2*=2
				}
				r=r*2
			}
		}
		ans1=dp[n-1].inject{|sum,e|
			sum+e
		}
		ans2=dp2[n-1].inject{|sum,e|
			sum+e
		}
		puts [ans1,ans2]*" "
	end
end
0