QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#771656 | #9597. Grade 2 | wcyQwQ# | RE | 0ms | 3660kb | C++14 | 517b | 2024-11-22 14:55:18 | 2024-11-22 14:55:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
cin.tie(0)->sync_with_stdio(0);
int x, n;
cin >> x >> n;
int lim = 1 << (int)ceil(log2(x));
vector<int> f(n + 1);
for (int i = 1; i <= lim; i++) {
f[i] = f[i - 1] + (__gcd<LL>((1ll * i * x) ^ x, x) == 1);
}
auto solve = [&](LL n) {
return (n / lim) * f[lim] + f[n % lim];
};
while (n--) {
LL l, r;
cin >> l >> r;
cout << solve(r) - solve(l - 1) << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
15 2 1 4 11 4514
output:
2 2252
result:
ok 2 lines
Test #2:
score: -100
Runtime Error
input:
500696 100000 110442401300 646889080214 337192 670162015551 508011001649 508011014425 94418501628 94418501634 824168677375 824168677376 732815842309 795402573302 353241304050 846773277757 622033633276 622033633284 760381702139 760381702143 207714 795408271057 382792 952061527685 686173 331215904334 ...