結果

問題 No.376 立方体のN等分 (2)
ユーザー maimai
提出日時 2016-06-05 01:26:30
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 589 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-04-17 03:37:54
合計ジャッジ時間 12,170 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 116 ms
12,416 KB
testcase_02 RE -
testcase_03 WA -
testcase_04 RE -
testcase_05 AC 115 ms
12,032 KB
testcase_06 AC 114 ms
12,288 KB
testcase_07 RE -
testcase_08 AC 153 ms
12,416 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 181 ms
12,544 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 175 ms
12,544 KB
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 110 ms
12,416 KB
testcase_26 WA -
testcase_27 AC 825 ms
12,544 KB
testcase_28 AC 117 ms
12,416 KB
testcase_29 RE -
testcase_30 WA -
testcase_31 AC 316 ms
12,672 KB
testcase_32 AC 832 ms
12,416 KB
testcase_33 AC 1,117 ms
12,416 KB
testcase_34 AC 612 ms
12,544 KB
testcase_35 RE -
testcase_36 AC 1,126 ms
12,416 KB
testcase_37 AC 1,128 ms
12,672 KB
testcase_38 RE -
testcase_39 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:9: warning: assigned but unused variable - resultL
Syntax OK

ソースコード

diff #

#
# (´・ω・`)
#

require 'prime'

n=gets.to_i

resultL=nil
resultH=n-1

div=[]
Prime.prime_division(n).each{|e|
    div+=[e[0]]*e[1]
}

div.sort!

if div.size==1
    printf("%d %d",resultH,resultH)
    exit
elsif div.size==2
    printf("%d %d",div[0]+div[1]-2,resultH)
    exit
end

min=nil
0.upto(div.size-2){|i|
    break if div[i]*div[i]*div[i]>n
    i+1.upto(div.size-1){|j|
        break if div[i]*div[j]*div[j]>n
        if (n%(div[i]*div[j])==0)
            t=(div[i]+div[j]+n/div[i]/div[j])
            min=t if !min||t
        end
    }
}

printf("%d %d",min-3,resultH)
exit
0