結果
| 問題 |
No.2393 Bit Grid Connected Component
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-28 22:23:01 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 4,030 ms |
| コンパイル使用メモリ | 162,756 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 19:33:46 |
| 合計ジャッジ時間 | 4,847 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 20 |
ソースコード
#include "bits/stdc++.h"
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;
void run() {
u64 x, y;
std::cin >> x >> y;
u64 base = std::__lg(x);
u64 ans = 0;
if (((x >> y) & 1) == 0) {
std::cout << "0\n";
}
else if (((x >> y) & 1) == 1 && ((x >> (y + 1)) & 1) == 0) {
std::cout << (1ull << (y + 1)) - 1 << "\n";
}
else {
do {
y++;
} while ((x >> (y + 1)) & 1);
std::cout << (1ull << (y + 1)) - 1 << "\n";
}
}
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
int t;
std::cin >> t;
for (int tcase = 0; tcase < t; tcase++) {
run();
}
return 0;
}