QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729357 | #9597. Grade 2 | yzhx# | WA | 154ms | 11476kb | C++20 | 948b | 2024-11-09 16:58:58 | 2024-11-09 16:58:58 |
Judging History
answer
#include <iostream>
#include <math.h>
#include <vector>
#include <functional>
#include <stdlib.h>
using namespace std;
using ll = long long;
ll gcd(ll i , ll j){
return j == 0 ? i : gcd(j , i % j);
}
void slove(){
ll x , n;
cin >> x >> n;
ll range = 1 << 21;
vector<int> pre(range);
pre[0] = 1;
for (ll i = 1 ; i < pre.size() ; i++){
pre[i] = pre[i - 1];
ll tmp = i * x;
tmp = (tmp + x) - (tmp ^ x);
if (gcd(tmp , x) != 1) pre[i]++;
}
function<ll(ll)> cal = [&](ll up){
ll ans = 0;
ans = (up / range) * pre.back();
ans += pre[up % range];
return ans;
};
while(n--){
ll l , r;
cin >> l >> r;
ll res = cal(r) - cal(l - 1);
cout << res << "\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
slove();
}
详细
Test #1:
score: 100
Accepted
time: 16ms
memory: 11476kb
input:
15 2 1 4 11 4514
output:
2 2252
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 154ms
memory: 11272kb
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:
536446678915 670161678360 12777 7 2 62586730994 493531973708 9 5 795408063344 952061144894 331215218162 8 25762 326860918364 5 56530 965533426782 854261347660 913963368493 553307119217 968734070526 286712511447 149883 5 20525921327 473160069017 8 352660 25791 4 337551905924 689087236686 11577 11 672...
result:
wrong answer 1st lines differ - expected: '0', found: '536446678915'