ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#214932 | #3855. 好数 | one_zero_four_zero | 100 | 2970ms | 5756kb | C++11 | 914b | 2024-11-24 09:46:57 | 2024-11-24 13:15:03 |
answer
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define MAXN 1000000000
using namespace std;
int Q;
long long l, r;
vector<long long> tmp[65];
inline 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 ++){
sort(tmp[i].begin(), tmp[i].end());
}
while (Q --){
scanf("%lld %lld", &l, &r);
long long ans = -1;
for (int i = 1; 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;
}
Details
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 30
Accepted
Test #1:
score: 30
Accepted
time: 28ms
memory: 5756kb
input:
1 999995700 1000000000
output:
-1
result:
ok Accepted! >_<
Test #2:
score: 0
Accepted
time: 84ms
memory: 5752kb
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 8370176 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok Accepted! >_<
Test #3:
score: 0
Accepted
time: 68ms
memory: 5752kb
input:
100000 3166357 3545086 7423160 8325545 9361438 9604609 5203715 5701815 8677014 9311476 6233360 68575...
output:
3178512 7471136 9437192 5242888 8912904 6291464 7077920 3145736 7946368 1638416 4259848 8912904 5783...
result:
ok Accepted! >_<
Test #4:
score: 0
Accepted
time: 114ms
memory: 5752kb
input:
100000 8250369 8255487 8119297 8124415 7857153 7862271 6284289 6289407 8373249 8378367 8365057 83701...
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:
ok Accepted! >_<
Test #5:
score: 0
Accepted
time: 84ms
memory: 5752kb
input:
100000 4183068 4187125 8115213 8119247 7332913 7337967 8373285 8378333 8246291 8250362 4183067 41871...
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:
ok Accepted! >_<
Test #6:
score: 0
Accepted
time: 67ms
memory: 5752kb
input:
100000 6511250 7509825 3016528 3835979 2753280 3654054 2828853 3543772 6676086 7585636 1336438 17936...
output:
6553616 3145736 3145736 3145736 6815760 1572872 2097156 4194308 1114120 7340048 5242888 4718600 1572...
result:
ok Accepted! >_<
Test #7:
score: 0
Accepted
time: 82ms
memory: 5756kb
input:
100000 8382464 8388611 7332864 7337983 8373248 8378367 8315904 8321023 4187136 4192255 8115200 81192...
output:
8382464 7332864 8373248 8315904 4187136 8115200 8360960 8378368 7853056 4183040 8107008 8303616 7320...
result:
ok Accepted! >_<
Test #8:
score: 0
Accepted
time: 82ms
memory: 5756kb
input:
100000 4187146 4192246 8348703 8353742 8378375 8382463 4183070 4187097 8360963 8365024 8344605 83486...
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:
ok Accepted! >_<
Test #9:
score: 0
Accepted
time: 66ms
memory: 5752kb
input:
100000 8803828 9608675 306374 314834 3032591 3831721 8888467 9081137 4801340 5285578 1056990 1788249...
output:
8912904 311312 3145736 8912904 5242888 1064968 3670032 3145736 8126528 8913936 6946848 6815760 13107...
result:
ok Accepted! >_<
Test #10:
score: 0
Accepted
time: 81ms
memory: 5752kb
input:
100000 8382465 8388612 7332865 7337984 8119297 8124416 6284289 6289408 8315905 8321024 4187137 41922...
output:
8388612 7337984 8124416 6289408 8321024 4192256 7332864 8250368 8119296 8315904 8365056 6284288 4187...
result:
ok Accepted! >_<
Test #11:
score: 0
Accepted
time: 85ms
memory: 5752kb
input:
100000 4187165 4192247 6284323 6289365 6284292 6289366 6284293 6289404 4183049 4187136 8315938 83210...
output:
-1 -1 -1 -1 4187136 -1 -1 -1 -1 -1 -1 -1 -1 4187136 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 8373248 -1 -1 -1 -...
result:
ok Accepted! >_<
Test #12:
score: 0
Accepted
time: 71ms
memory: 5752kb
input:
100000 4286975 4908307 9683477 9930904 8579514 9296546 3589230 4452606 2022097 2617062 9222988 93909...
output:
4325384 9699344 8650760 4194308 2097156 9240608 524292 3407888 7372832 4194308 1052680 8650760 62914...
result:
ok Accepted! >_<
Subtask #2:
score: 30
Accepted
Test #13:
score: 30
Accepted
time: 89ms
memory: 5752kb
input:
100000 8382464 8388612 7332864 7337984 8250368 8255488 8119296 8124416 8373248 8378368 8348672 83537...
output:
8388612 7332864 8250368 8119296 8373248 8348672 8315904 4187136 8246272 8311808 8344576 6280192 4178...
result:
ok Accepted! >_<
Test #14:
score: 0
Accepted
time: 68ms
memory: 5756kb
input:
100000 330807594 855120061 2739043 698283851 6893055 483485075 87223028 335275196 436165546 84345741...
output:
536870916 4194308 8388612 134217732 536870916 268435460 939524112 536870916 536870916 536870916 1677...
result:
ok Accepted! >_<
Test #15:
score: 0
Accepted
time: 51ms
memory: 5756kb
input:
100000 775803569 969702803 85461932 615601357 762866118 893251725 250087967 904974579 155037438 6394...
output:
805306376 134217732 805306376 268435460 268435460 536870916 671088648 671088648 536870916 671088648 ...
result:
ok Accepted! >_<
Test #16:
score: 0
Accepted
time: 64ms
memory: 5756kb
input:
100000 130615964 543185019 196269565 471109044 219486005 225290312 698409571 899750338 411258373 754...
output:
134217732 268435460 220200992 805306376 536870916 33554436 209715216 268435460 268435460 805306376 5...
result:
ok Accepted! >_<
Test #17:
score: 0
Accepted
time: 58ms
memory: 5756kb
input:
100000 255723571 895551031 508758301 569794703 40263079 330048659 113440683 868414377 950208385 9778...
output:
268435460 536870916 67108868 134217732 956301344 536870916 117440528 536870916 536870916 33554436 67...
result:
ok Accepted! >_<
Test #18:
score: 0
Accepted
time: 70ms
memory: 5756kb
input:
100000 104553077 989562637 10120318 724797962 158309830 678524578 557884646 983322572 58146931 97361...
output:
134217732 16777220 268435460 570425352 67108868 402653192 268435460 822083600 16777220 268435460 268...
result:
ok Accepted! >_<
Test #19:
score: 0
Accepted
time: 58ms
memory: 5752kb
input:
100000 453986044 643127299 62050080 325153194 213493974 507329641 169830974 860259287 330899407 7438...
output:
536870916 67108868 268435460 268435460 536870916 134217732 671088648 134217732 134217732 268435460 8...
result:
ok Accepted! >_<
Test #20:
score: 0
Accepted
time: 63ms
memory: 5756kb
input:
100000 59899167 304158243 44764825 925280222 175022152 410288846 263464485 665242780 351885365 95203...
output:
67108868 67108868 268435460 268435460 536870916 805306376 570425352 805306376 536870916 301989896 26...
result:
ok Accepted! >_<
Test #21:
score: 0
Accepted
time: 56ms
memory: 5756kb
input:
100000 247294342 765596808 22498929 72278665 409838880 678769102 330937103 851913510 431099294 51949...
output:
268435460 33554436 536870916 536870916 436207632 67108868 536870916 536870916 268435460 536870916 34...
result:
ok Accepted! >_<
Test #22:
score: 0
Accepted
time: 61ms
memory: 5752kb
input:
100000 609469149 937829398 741752 437102813 127563047 952873626 80617897 400333252 239724969 6302970...
output:
671088648 1048580 134217732 134217732 268435460 536870916 536870916 536870916 939524112 301989896 26...
result:
ok Accepted! >_<
Test #23:
score: 0
Accepted
time: 59ms
memory: 5756kb
input:
100000 365447063 782245369 485718533 809336092 328659366 905072830 4285772 26561306 232286466 967710...
output:
536870916 536870916 536870916 8388612 268435460 536870916 134217732 268435460 536870916 67108868 536...
result:
ok Accepted! >_<
Test #24:
score: 0
Accepted
time: 49ms
memory: 5756kb
input:
100000 161998019 732149668 13514251 779577691 542181786 554173783 52348119 840210025 642210525 78738...
output:
268435460 16777220 545259528 67108868 671088648 67108868 671088648 268435460 150994952 536870916 402...
result:
ok Accepted! >_<
Subtask #3:
score: 40
Accepted
Test #25:
score: 40
Accepted
time: 64ms
memory: 5752kb
input:
100000 399579116 591906314 740833634 945801951 571383727 687256424 802141272 968687299 451896528 771...
output:
536870916 805306376 603979784 805306376 536870916 419430416 536870916 536870916 134217732 268435460 ...
result:
ok Accepted! >_<
Test #26:
score: 0
Accepted
time: 101ms
memory: 5752kb
input:
100000 796860417 796901341 804724751 804765668 536821802 536870903 771694642 771735519 973021233 973...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 796860416 -1 -1 -1 -1 -1 -1 -1 805158912 -1 -1 -1 -1 -1 -1 -1...
result:
ok Accepted! >_<
Test #27:
score: 0
Accepted
time: 103ms
memory: 5752kb
input:
100000 143224219 144088533 256791488 257781238 543839423 544640061 942539426 943186316 716874801 717...
output:
143654928 256901248 544210976 942669888 717226048 321912896 219152416 418381952 711983232 14680080 4...
result:
ok Accepted! >_<
Test #28:
score: 0
Accepted
time: 143ms
memory: 5756kb
input:
100000 939474945 939524111 989798401 989839359 503259137 503300095 796860417 796901375 804724737 804...
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:
ok Accepted! >_<
Test #29:
score: 0
Accepted
time: 86ms
memory: 5752kb
input:
100000 931078162 931119072 536821766 536870881 536682515 536723417 536821806 536870893 973021205 973...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 796860416 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
ok Accepted! >_<
Test #30:
score: 0
Accepted
time: 96ms
memory: 5756kb
input:
100000 340633188 341332987 60400081 60442294 476731983 477175828 992672021 993450108 596640240 59706...
output:
340787232 60424320 477102208 993001728 596640384 510526464 76546064 899940608 421003328 304087056 59...
result:
ok Accepted! >_<
Test #31:
score: 0
Accepted
time: 112ms
memory: 5752kb
input:
100000 939474944 939524111 536821760 536870915 528424960 528465919 939204608 939245567 520036352 520...
output:
939474944 536821760 528424960 939204608 520036352 989798400 503259136 805183488 973021184 998187008 ...
result:
ok Accepted! >_<
Test #32:
score: 0
Accepted
time: 90ms
memory: 5756kb
input:
100000 536821792 536870905 528425007 528465911 536748035 536788975 536289316 536330219 528424960 528...
output:
-1 -1 -1 -1 528424960 -1 805183488 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok Accepted! >_<
Test #33:
score: 0
Accepted
time: 100ms
memory: 5752kb
input:
100000 479266675 479640744 653516336 654473738 784390885 784940472 410201498 410578138 357486596 357...
output:
479330432 654311456 784400640 410255488 357564480 697303104 875561024 583532608 436928640 508035200 ...
result:
ok Accepted! >_<
Test #34:
score: 0
Accepted
time: 114ms
memory: 5752kb
input:
100000 805257217 805306376 939204609 939245568 536289281 536330240 989798401 989839360 503259137 503...
output:
805306376 939245568 536330240 989839360 503300096 805224448 535805952 931119104 469745664 771735552 ...
result:
ok Accepted! >_<
Test #35:
score: 0
Accepted
time: 91ms
memory: 5752kb
input:
100000 528425008 528465878 520036398 520077284 939204651 939245541 805257222 805306338 469704725 469...
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:
ok Accepted! >_<
Test #36:
score: 0
Accepted
time: 102ms
memory: 5756kb
input:
100000 877733125 878206664 184434749 184790814 546805355 547295380 287469447 287483492 325021440 325...
output:
877789312 184549392 546832416 287473728 325058624 513802368 95551616 117440528 748159104 924189184 4...
result:
ok Accepted! >_<
Test #37:
score: 0
Accepted
time: 110ms
memory: 5752kb
input:
100000 805257216 805306376 536821760 536870916 536289280 536330240 520036352 520077312 503259136 503...
output:
805306376 536870916 536289280 520036352 503259136 973021184 804724736 535764992 998187008 805117952 ...
result:
ok Accepted! >_<
Extra Test:
score: 0
Extra Test Passed