結果

問題 No.3236 累乗数大好きbot
ユーザー tomerun
提出日時 2025-08-15 21:52:09
言語 Crystal
(1.14.0)
結果
RE  
実行時間 -
コード長 385 bytes
コンパイル時間 11,806 ms
コンパイル使用メモリ 311,780 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-15 21:54:58
合計ジャッジ時間 13,880 ms
ジャッジサーバーID
(参考情報)
judge3 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 RE * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

h = Hash(Int64, Int32).new
3.upto(40) do |p|
  b = 2i64
  while true
    u = b ** p
    break if u > 1_000_000_000_000i64
    h[u] = p
    b += 1
  end
end
read_line.to_i.times do
  n = read_line.to_i64
  if h.has_key?(n)
    puts h[n]
  else
    sq = (n ** 0.5).to_i
    if (sq - 1) ** 2 == n || sq ** 2 == n || (sq + 1) ** 2 == n
      puts 2
    else
      puts 1
    end
  end
end
0