QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#267437 | #7738. Equivalent Rewriting | 20231127 | WA | 0ms | 3676kb | C++14 | 1.1kb | 2023-11-27 11:37:25 | 2023-11-27 11:37:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll p, m;
void solve() {
cin >> p >> m;
ll pp = p - 1;
ll sum = 0, ans = 0;
for (int i = 60; i >= 0; i--) {
ll k = (1ll << i), mx, mn, L, R;
if (i == 0) {
mn = sum, mx = sum;
if ((k & pp) || (k & m)) mx++;
if ((k & pp) && !(k & m)) mn++;
mn = max(0ll, mn - 1), mx = max(0ll, mx - 1);
L = (mn / p) + ((mn % p) ? 1 : 0), R = mx / p;
ans += (R - L + 1);
} else {
if ((k & pp) && (k & m)) {
mn = sum + k, mx = sum + k + k - 1;
mn = max(0ll, mn - 1), mx = max(0ll, mx - 1);
L = (mn / p) + ((mn % p) ? 1 : 0), R = mx / p;
ans += (R - L + 1);
} else if (k & m) {
mn = sum, mx = sum + k - 1;
mn = max(0ll, mn - 1), mx = max(0ll, mx - 1);
L = (mn / p) + ((mn % p) ? 1 : 0), R = mx / p;
ans += (R - L + 1);
sum += k;
} else if (k & pp) {
sum += k;
}
}
// cout << mn << " " << mx << " " << sum << "\n";
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int t;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3676kb
input:
3 3 6 3 3 1 5 2 5 3 2 2 6 2 3 3 1 3 2 2 3 1 1 3 2 2 1
output:
3 1 5
result:
wrong answer Token parameter [name=yesno] equals to "3", doesn't correspond to pattern "Yes|No" (test case 1)