結果

問題 No.300 平方数
ユーザー Leonardone
提出日時 2015-11-17 05:51:37
言語 Ruby
(3.4.1)
結果
AC  
実行時間 396 ms / 1,000 ms
コード長 263 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-09-13 15:54:07
合計ジャッジ時間 9,717 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
Syntax OK

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU

x = gets.to_i

def f (x, k)
    loop { d, m = x.divmod k; break if m != 0; x = d; }; x 
end

x = f(x, 4)

3.step(x ** 0.5, 2) do |k|
    kk = k * k
    break if x < kk
    x = f(x, kk)
end

puts x
0