結果

問題 No.2393 Bit Grid Connected Component
ユーザー ochiaigawa
提出日時 2023-07-28 21:34:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 194,552 KB
最終ジャッジ日時 2025-02-15 20:06:04
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<long long> c(61);
void solve() {
  long long x;
  int y;
  cin >> x >> y;
  if(!(x >> y & 1)) {
    cout << 0 << '\n';
  } else {
    int i = 0;
    while(x >> y & 1) {
      y++;
    }
    cout << c[y - 1] << '\n';
  }
}
int main() {
  c[0] = 1;
  for(int i = 1; i < 61; i++) {
    c[i] = c[i - 1] + (1LL << i);
  }
  int T;
  cin >> T;
  while(T--) {
    solve();
  }
  return 0;
}
0