結果
問題 |
No.2393 Bit Grid Connected Component
|
ユーザー |
![]() |
提出日時 | 2023-07-29 00:15:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 606 bytes |
コンパイル時間 | 1,899 ms |
コンパイル使用メモリ | 193,608 KB |
最終ジャッジ日時 | 2025-02-15 20:47:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; string change_base(long long n, int base, int siz=0) { string ret; if (n==0) { ret.push_back('0'); } while (n>0) { ret.push_back(n%base+'0'); n/=base; } if (siz) { while (ret.size()<siz) { ret.push_back('0'); } } return ret; } int main() { int t; cin>>t; while (t--) { long long x; int y; cin>>x>>y; string bin=change_base(x,2,60); int r=y; while (r<60&&bin[r]=='1') { r++; } long long ans=0; for (int i=0;i<r;i++) { ans+=1ll<<i; } cout<<ans<<endl; } }