結果

問題 No.2393 Bit Grid Connected Component
ユーザー Today03
提出日時 2023-07-29 00:14:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 194,032 KB
最終ジャッジ日時 2025-02-15 20:47:26
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 13 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

string change_base(int 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;
  }
}
0