結果

問題 No.300 平方数
ユーザー 👑 yumechiyumechi
提出日時 2015-11-13 23:51:02
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 346 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 21,216 KB
最終ジャッジ日時 2023-10-11 17:05:51
合計ジャッジ時間 11,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
15,284 KB
testcase_01 AC 95 ms
15,500 KB
testcase_02 AC 231 ms
18,348 KB
testcase_03 AC 92 ms
15,212 KB
testcase_04 AC 92 ms
15,084 KB
testcase_05 WA -
testcase_06 AC 92 ms
15,340 KB
testcase_07 AC 93 ms
15,224 KB
testcase_08 AC 93 ms
15,384 KB
testcase_09 AC 92 ms
15,196 KB
testcase_10 AC 92 ms
15,400 KB
testcase_11 AC 92 ms
15,232 KB
testcase_12 AC 97 ms
15,516 KB
testcase_13 WA -
testcase_14 AC 112 ms
15,720 KB
testcase_15 AC 229 ms
18,104 KB
testcase_16 AC 226 ms
18,136 KB
testcase_17 AC 362 ms
20,868 KB
testcase_18 AC 112 ms
15,696 KB
testcase_19 AC 165 ms
16,764 KB
testcase_20 WA -
testcase_21 AC 358 ms
20,912 KB
testcase_22 AC 359 ms
21,088 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 175 ms
15,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 168 ms
15,336 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 127 ms
15,344 KB
testcase_34 AC 179 ms
15,368 KB
testcase_35 AC 150 ms
15,356 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 230 ms
18,140 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 227 ms
18,140 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'
x = gets.to_i
if Prime.prime?(x) || x == 1
    puts x
    exit(0)
end

res = 1
arr = Prime.each(Math.sqrt(x).to_i + 1).to_a
for a in arr do
    if x == 1
        puts res
        exit(0)
    end
    cnt = 0
    while x % a == 0 do
        x /= a
        cnt += 1
    end
    if cnt % 2 == 1
        res *= a
    end
end

puts res
0