QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#729476 | #9597. Grade 2 | yzhx# | WA | 145ms | 19508kb | C++20 | 1.1kb | 2024-11-09 17:12:07 | 2024-11-09 17:12:08 |
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;
// cout << range << endl;
vector<ll> 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];
// cout << "up : " << up << " " << ans << endl;
return ans;
};
// cout << range << endl;
// cout << pre.back() << endl;
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: 14ms
memory: 19464kb
input:
15 2 1 4 11 4514
output:
2 2252
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 145ms
memory: 19508kb
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:
255797 319558 0 0 0 29844 235334 0 0 379280 453978 157936 0 0 155859 0 0 460402 407343 435812 263837 461928 136715 0 0 9788 225620 0 0 0 1 160957 328582 0 0 320811 169585 373540 85495 1 0 137264 0 259527 0 176026 185491 0 0 0 434941 1 196346 0 0 0 0 167362 0 186835 0 0 0 0 445809 0 247083 0 80757 15...
result:
wrong answer 1st lines differ - expected: '0', found: '255797'