結果
問題 | No.1286 Stone Skipping |
ユーザー |
|
提出日時 | 2020-11-15 17:38:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 510 bytes |
コンパイル時間 | 2,808 ms |
コンパイル使用メモリ | 191,040 KB |
最終ジャッジ日時 | 2025-01-16 00:59:28 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | lint d; scanf("%lld",&d); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ lint d; scanf("%lld",&d); auto dist=[](lint x,int n){ lint res=0; rep(i,n+1) res+=x, x/=2; return res; }; lint ans=d; rep(n,61){ // 跳ね返る回数 lint lo=1LL<<n,hi=d+1; if(lo>hi) continue; while(hi-lo>1){ lint mi=(lo+hi)/2; if(dist(mi,n)<d) lo=mi; else hi=mi; } if(dist(hi,n)==d) ans=min(ans,hi); } printf("%lld\n",ans); return 0; }