0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:52:02 +00:00
https://sjzezoj.com/submission/21493
This commit is contained in:
Baoshuo Ren 2021-08-23 22:26:50 +08:00 committed by Baoshuo Ren
parent 45c209072e
commit 4f6248c621
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
S2OJ/12/12.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int t;
long long n, s;
int main() {
cin >> t;
while (t--) {
cin >> n >> s;
if (s) {
cout << (n + 1 >> 1) << endl;
} else if (n & 1) {
cout << (n >> 1) << endl;
} else {
for (int i = 1; i <= 30; i++) {
if ((1ll << (i - 1)) <= n && n < (1ll << i)) {
cout << ((n - (1ll << i - 1)) >> 1) << endl;
break;
}
}
}
}
return 0;
}