結果

問題 No.2393 Bit Grid Connected Component
ユーザー Today03Today03
提出日時 2023-07-29 00:14:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 194,732 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 08:06:50
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 16 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

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