結果
問題 | No.1869 Doubling? |
ユーザー |
|
提出日時 | 2021-11-23 16:16:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 345 bytes |
コンパイル時間 | 1,750 ms |
コンパイル使用メモリ | 191,580 KB |
最終ジャッジ日時 | 2025-01-26 00:45:27 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ long long n,x; cin>>n>>x; long long s=0,cnt=0; while(x-1){ cnt++; s+=x; if(x&1)x=(x+1)/2; else x/=2; } if(cnt>=n){ long long ans=0,tmp=1; for(int i=0;i<n;i++){ ans+=tmp; tmp*=2; } cout<<ans<<endl; } else cout<<s+(n-cnt)<<endl; }