QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#499914 | #6730. Coolbits | Au_Gold | WA | 0ms | 3608kb | C++20 | 1.5kb | 2024-07-31 20:10:30 | 2024-07-31 20:10:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int N = 1e5 + 5, M = 1e4 + 5, mod = 7;
ll n, l[N], r[N], par;
void solve()
{
cin >> n;
ll minr = LONG_LONG_MAX;
for (ll i = 1; i <= n; i++)
{
cin >> l[i] >> r[i];
minr = min(minr, r[i]);
}
ll wei = minr & -minr, ans = minr;
for (ll i = 1; i <= n; i++)
{
if (r[i] == minr)
continue;
if (l[i] >= (1 << wei + 1)) // 如果 l大于等于2^(wei+1)
{
ll lb = l[i], res = 0;
for (ll i = 0; i <= wei; i++) // 取出l的二进制低wei位
{
if (l[i] >> i & 1)
res = res + (1 << i);
}
if (r[i] - l[i] >= (1 << wei + 1) - res) // 当r与l的差 大于等于 (1 << wei + 1)与l的二进制低wei位的差 时才有
ans = ans & ((1 << wei + 1) - 1);
else
ans = ans & r[i];
}
else if (l[i] < (1 << wei + 1)) // 如果l在[ 2^wei,2^(wei+1) )内
{
if (r[i] < (1 << wei + 1)) // 如果r在(2^wei,2^(wei+1))
ans = ans & r[i];
else if (r[i] >= (1 << wei + 1)) // 如果r大于等于2^(wei+1)
ans = ans & ((1 << wei + 1) - 1);
}
}
cout << ans << endl;
}
/*
2
3
0 8
2 6
3 9
1
1 100
3
10 17
2 6
3 9
*/
int main()
{
int t = 1;
//cin >> t;
while (t--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3608kb
input:
2 3 0 8 2 6 3 9 1 1 100
output:
0
result:
wrong answer 1st numbers differ - expected: '6', found: '0'