結果
| 問題 |
No.1957 Xor Min
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-18 18:16:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 480 bytes |
| コンパイル時間 | 2,027 ms |
| コンパイル使用メモリ | 193,152 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-18 18:16:18 |
| 合計ジャッジ時間 | 3,420 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool isPowerofTwo(int n) {
// Check if n is positive and n & ~(n-1) equals n
return (n > 1) && ((n & (~(n-1))) == n);
}
int main() {
long long int a,c;
cin >> a >>c;
if(a>c) swap(a,c);
long long int val = log2(c);
long long int ans = 1;
if(isPowerofTwo(a) && isPowerofTwo(c) && a!=c) ans++;
ans = ans << val;
ans--;
ans = min(ans, a);
cout << ans;
// your code goes here
}