結果

問題 No.300 平方数
ユーザー shi-moshi-mo
提出日時 2016-10-26 00:19:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 393 ms / 1,000 ms
コード長 336 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 11,208 KB
実行使用メモリ 20,604 KB
最終ジャッジ日時 2023-08-15 19:20:42
合計ジャッジ時間 11,514 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,092 KB
testcase_01 AC 79 ms
15,084 KB
testcase_02 AC 203 ms
18,228 KB
testcase_03 AC 78 ms
15,288 KB
testcase_04 AC 79 ms
15,048 KB
testcase_05 AC 79 ms
15,152 KB
testcase_06 AC 78 ms
15,316 KB
testcase_07 AC 79 ms
15,044 KB
testcase_08 AC 78 ms
15,248 KB
testcase_09 AC 77 ms
15,148 KB
testcase_10 AC 77 ms
15,244 KB
testcase_11 AC 81 ms
15,112 KB
testcase_12 AC 79 ms
15,556 KB
testcase_13 AC 393 ms
20,268 KB
testcase_14 AC 98 ms
15,788 KB
testcase_15 AC 197 ms
18,140 KB
testcase_16 AC 196 ms
18,280 KB
testcase_17 AC 311 ms
20,228 KB
testcase_18 AC 94 ms
15,744 KB
testcase_19 AC 141 ms
17,136 KB
testcase_20 AC 145 ms
16,956 KB
testcase_21 AC 324 ms
20,604 KB
testcase_22 AC 327 ms
20,532 KB
testcase_23 AC 316 ms
20,600 KB
testcase_24 AC 197 ms
18,348 KB
testcase_25 AC 152 ms
15,284 KB
testcase_26 AC 199 ms
18,116 KB
testcase_27 AC 205 ms
18,132 KB
testcase_28 AC 147 ms
15,240 KB
testcase_29 AC 314 ms
20,544 KB
testcase_30 AC 319 ms
20,364 KB
testcase_31 AC 315 ms
20,440 KB
testcase_32 AC 198 ms
18,092 KB
testcase_33 AC 108 ms
15,556 KB
testcase_34 AC 153 ms
15,472 KB
testcase_35 AC 131 ms
15,304 KB
testcase_36 AC 202 ms
18,056 KB
testcase_37 AC 205 ms
18,248 KB
testcase_38 AC 201 ms
18,168 KB
testcase_39 AC 207 ms
18,064 KB
testcase_40 AC 201 ms
18,340 KB
testcase_41 AC 140 ms
17,076 KB
testcase_42 AC 202 ms
18,144 KB
testcase_43 AC 313 ms
20,592 KB
testcase_44 AC 202 ms
18,116 KB
testcase_45 AC 139 ms
16,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

x = gets.to_i

if Prime.prime?(x)
  puts x
  exit 0
end

d = [1]
q = [1]
Prime.each(Math.sqrt(x)) do |i|
  next if 0 != x % i

  n = x
  while 0 == n % i
    n /= i
    d << i

    if q.include?(i)
      q.delete(i)
      next
    end

    q << i
  end
end

y = x / d.inject(:*)
if 1 < y
  q << y
end

puts q.inject(:*)
0