結果

問題 No.375 立方体のN等分 (1)
ユーザー suppy193suppy193
提出日時 2016-07-11 16:13:51
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 1,011 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-04-21 12:50:31
合計ジャッジ時間 8,762 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,288 KB
testcase_01 AC 85 ms
12,288 KB
testcase_02 AC 260 ms
13,056 KB
testcase_03 AC 86 ms
12,288 KB
testcase_04 AC 85 ms
12,288 KB
testcase_05 AC 85 ms
12,288 KB
testcase_06 AC 85 ms
12,416 KB
testcase_07 AC 86 ms
12,416 KB
testcase_08 AC 260 ms
12,800 KB
testcase_09 AC 86 ms
12,672 KB
testcase_10 AC 88 ms
12,544 KB
testcase_11 AC 86 ms
12,416 KB
testcase_12 AC 88 ms
12,288 KB
testcase_13 AC 95 ms
12,288 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:37: warning: assigned but unused variable - set
Syntax OK

ソースコード

diff #

require 'prime'
p_arr = []
n = gets.strip.to_i
p = n.prime_division
#p p
p.each do |pf|
	pf[1].times do
		p_arr << pf[0]	
	end
end
min = Float::INFINITY
#p p_arr
(1..(p_arr.length - 1)).each do |i|
	p_arr.combination(i).each do |set1|
		#p set1
		p2_arr = p_arr.clone
		set1.each do |n|
			if p2_arr.index(n) != nil
				p2_arr[p2_arr.index(n)] = nil
			end
		end
		p2_arr.compact!
		#p p2_arr
		(1..(p2_arr.length)).each do |j|
			p2_arr.combination(j).each do |set2|
				#p set2
				#next if set2 == [nil]
				p3_arr = p2_arr.clone
				set2.each do |m|
					if p3_arr.index(m) != nil
						p3_arr[p3_arr.index(m)] = nil
					end
				end
				set3 = p3_arr.compact!
				#p set3
				#next if set3 == [nil]
				set = [set1, set2, set3]
				#p set
				num = set1.inject(:*) - 1 + set2.inject(:*) - 1
				if set3.length != 0
					num += set3.inject(:*) - 1
				end
				if num < min
					min = num
				end
			end
		end

	end
end
if min == Float::INFINITY
	print "#{n - 1}"
else
	print "#{min}"
end
print " #{n - 1}\n"
0