結果

問題 No.414 衝動
ユーザー 👑 yumechiyumechi
提出日時 2016-08-26 22:27:42
言語 Ruby
(3.3.0)
結果
AC  
実行時間 287 ms / 1,000 ms
コード長 212 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 11,292 KB
実行使用メモリ 15,608 KB
最終ジャッジ日時 2023-08-09 13:20:05
合計ジャッジ時間 3,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
15,440 KB
testcase_01 AC 90 ms
15,192 KB
testcase_02 AC 90 ms
15,240 KB
testcase_03 AC 287 ms
15,348 KB
testcase_04 AC 90 ms
15,244 KB
testcase_05 AC 180 ms
15,608 KB
testcase_06 AC 181 ms
15,428 KB
testcase_07 AC 89 ms
15,328 KB
testcase_08 AC 143 ms
15,428 KB
testcase_09 AC 280 ms
15,400 KB
testcase_10 AC 88 ms
15,208 KB
testcase_11 AC 91 ms
15,408 KB
testcase_12 AC 89 ms
15,324 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

i = gets.chomp.to_i
if Prime.prime?(i) || i == 1
  puts "1 #{i}"
else
  arr = i.prime_division.map {|p,n| [p]*n }.flatten
  a = arr.inject {|sum, n| sum * n } / arr[0]
  puts "#{arr[0]} #{a}"
end
0