QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#771656#9597. Grade 2wcyQwQ#RE 0ms3660kbC++14517b2024-11-22 14:55:182024-11-22 14:55:19

Judging History

你现在查看的是最新测评结果

  • [2024-11-22 14:55:19]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3660kb
  • [2024-11-22 14:55:18]
  • 提交

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;
}

詳細信息

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
...

output:


result: