結果
| 問題 | No.1664 Unstable f(n) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-05 00:30:35 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 443 bytes |
| 記録 | |
| コンパイル時間 | 1,679 ms |
| コンパイル使用メモリ | 172,676 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 12:19:46 |
| 合計ジャッジ時間 | 2,785 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
Main.d(4): Deprecation: function `std.math.exponential.log2` is deprecated - `std.math.exponential.log2` called with argument types `(long)` matches both `log2(real)`, `log2(double)`, and `log2(float)`. Cast argument to floating point type instead.
ソースコード
import std;
void main(){
auto n=readln.chomp.to!(long);
long j=cast(long)log2(n);
long m=n;
for(;j>0;j--){
long i=(n^^(1.0/j)).lrint;
long k=n-(i^^j);
long kp=n-((i+1)^^j);
long km=n-((i-1)^^j);
/*
stderr.writefln("%d %d %d",i,j,k);
stderr.writefln("%d %d %d",i,j,kp);
stderr.writefln("%d %d %d",i,j,km);
*/
if(k>=0) m=min(i+j+k,m);
if(kp>=0) m=min(i+1+j+kp,m);
if(i>0&&km>=0) m=min(i-1+j+km,m);
}
writeln(m);
}