結果

問題 No.2393 Bit Grid Connected Component
ユーザー Today03Today03
提出日時 2023-07-29 00:15:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 606 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 194,284 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 08:07:51
合計ジャッジ時間 4,454 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 13 ms
6,940 KB
testcase_15 AC 17 ms
6,944 KB
testcase_16 AC 103 ms
6,944 KB
testcase_17 AC 347 ms
6,940 KB
testcase_18 AC 345 ms
6,944 KB
testcase_19 AC 349 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0