ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214928 | #3855. 好数 | one_zero_four_zero | 0 | 120ms | 8196kb | C++11 | 947b | 2024-11-24 09:32:25 | 2024-11-24 13:14:43 |
answer
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define MAXN 2000000000
using namespace std;
int Q;
long long l, r;
vector<long long> tmp[65];
void dfs(long long val, int cnt){
tmp[cnt].push_back(val << cnt);
for (int i = 1; ; i ++){
if ((((val << i) | 1) << (cnt + 1)) > MAXN) return;
dfs((val << i) | 1, cnt + 1);
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("../data.in", "r", stdin);
freopen("../data.out", "w", stdout);
#endif
scanf("%d", &Q);
dfs(1, 1);
/*
for (int i = 0; i <= 64; i ++){
for (auto && j : tmp[i]){
cout << j << " ";
}
cout << "\n";
}
*/
while (Q --){
scanf("%lld %lld", &l, &r);
long long ans = -1;
for (int i = 0; i < 32; i ++){
int pos = lower_bound(tmp[i].begin(), tmp[i].end(), l) - tmp[i].begin();
if (pos >= tmp[i].size() || tmp[i][pos] > r) continue;
ans = tmp[i][pos];
break;
}
printf("%lld\n", ans);
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 30
Accepted
time: 7ms
memory: 8196kb
input:
1 999995700 1000000000
output:
-1
result:
ok Accepted! >_<
Test #2:
score: -30
Wrong Answer
time: 58ms
memory: 8196kb
input:
100000 7857167 7862247 8344618 8348655 8382478 8388566 8315927 8321011 8246290 8250342 8382480 83885...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...
result:
wrong answer There is a valid number but you did not find it.
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 55ms
memory: 8196kb
input:
100000 8382464 8388612 7332864 7337984 8250368 8255488 8119296 8124416 8373248 8378368 8348672 83537...
output:
8388612 -1 -1 -1 8373248 -1 -1 4187136 -1 -1 -1 -1 4178432 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
wrong answer There is a valid number but you did not find it.
Subtask #3:
score: 0
Skipped