結果
問題 | No.1286 Stone Skipping |
ユーザー |
|
提出日時 | 2020-11-13 21:30:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 848 ms |
コンパイル使用メモリ | 67,072 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 09:49:35 |
合計ジャッジ時間 | 1,419 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 10 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; long D; long ans; long f(int k,int l) { return (1L<<k+1)-1-(k>l?(1L<<k-l)-1:0); } main() { cin>>D; ans=D; for(int k=1;;k++) { if(1L<<k-1>D)break; for(int l=1;l<=k;l++) { long now=D; long st=1L<<k-1; now-=f(k-1,l); for(int i=k-2;i>=0;i--) { long t=f(i,l); if(now>=t) { now-=t; st|=1L<<i; } } if(now==0) { ans=min(ans,st); } } } cout<<ans<<endl; }