QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#500113 | #6730. Coolbits | Au_Gold | WA | 465ms | 5116kb | C++20 | 1.5kb | 2024-07-31 22:34:24 | 2024-07-31 22:34:24 |
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)
ans = ans & r[i];
// else// 当r与l的差 大于等于 (1 << wei + 1)与l的二进制低wei位的差 时才有
// ans = ans & ((1 << wei + 1) - 1);
}
else
{ // 如果l在小于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
8 10
2 6
3 9
*/
int main()
{
int t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3692kb
input:
2 3 0 8 2 6 3 9 1 1 100
output:
6 100
result:
ok 2 number(s): "6 100"
Test #2:
score: -100
Wrong Answer
time: 465ms
memory: 5116kb
input:
1117 74 234256176 451122435 614716780 701954053 31102604 284818525 528763990 809400397 40637446 612671528 329403504 936190213 112402633 729525189 248142852 481053286 30877745 700834811 529884578 749041634 146522084 758550567 934650972 996096650 538751855 856147351 170918541 975066425 253153230 35361...
output:
93281727 178897983 605885728 115213978 156709101 48236211 88265286 150841039 171994003 310407464 144137157 42855333 68315319 120900807 114930940 76692399 434316427 99517528 55894474 135007650 271902974 83920537 205049062 86118041 405496044 59618653 55717970 75700110 312760218 91784122 57712698 24424...
result:
wrong answer 1st numbers differ - expected: '29882460', found: '93281727'