結果
問題 |
No.1664 Unstable f(n)
|
ユーザー |
![]() |
提出日時 | 2021-09-03 21:46:59 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 270 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2024-12-15 11:55:32 |
合計ジャッジ時間 | 5,564 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 12 |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - j Syntax OK
ソースコード
n=gets.to_i rr=(n**0.5).floor j=1 ans=n 2.upto(60) do |j| l=1 r=rr+1 i=(l+r)/2 while r-l>1 i=(l+r)/2 if i**j<=n l=i else r=i end end rr=r ij=i**j if n-ij>=0 ans=i+j+n-ij if ans>i+j+n-ij else break end end puts ans