QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#748505 | #9597. Grade 2 | xdz_ | WA | 86ms | 11672kb | C++14 | 1.3kb | 2024-11-14 20:35:31 | 2024-11-14 20:35:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define endl '\n'
typedef pair<int,int> PII;
void solve(){
int n,x;
cin >>x>>n;
int y = x,num = 0;
while(y){
num ++;
y /= 2;
}
int zz = pow(2,num);
vector<int> s(zz + 1);
for(int i = 1;i <= zz;i ++){
int z = (i * x) ^ x;
int z1 = __gcd(z,x);
if(z1 == 1){
s[i] = s[i - 1] + 1;
}
else s[i] = s[i - 1];
}
// for(int i = 0;i < zz;i++) s[i] = s[i+1];
// int t = zz;
// cout<<"zz "<<zz<<endl;
// for(int i = 1;i <= zz;i ++) cout<<s[i]<<" ";
// cout<<endl;
for(int i = 1;i <= n;i ++){
int l,r;
cin >>l>>r;
int sum = 0;
if(r - l + 1 >= zz){
int k = r - l + 1;
sum += k / zz * s[zz];
k -= k / zz * zz;
int fl = l - l / zz * zz,fr = r - r / zz * zz;
if(fr >= fl){
sum += s[fr] - s[fl - 1];
}
else{
sum += s[zz] - s[fl - 1];
sum += s[fr];
}
}
else{
int fl = l - l / zz * zz,fr = r - r / zz * zz;
if(fr >= fl){
sum += s[fr] - s[fl - 1];
}
else{
sum += s[zz] - s[fl - 1];
sum += s[fr];
}
}
cout<<sum<<endl;
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T;
T = 1;
// cin>>T;
while(T --){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
15 2 1 4 11 4514
output:
2 2252
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 47ms
memory: 7496kb
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:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #3:
score: 0
Accepted
time: 47ms
memory: 7540kb
input:
465262 100000 119442423888 249533375982 528365238401 528365275157 654839906300 654839906303 135820863700 135820967840 336231 918143221477 568175915485 568176067832 993015103483 993015103488 951474 444595379179 298623434750 298623434751 257961 410491919396 996297715292 996297994388 17765498878 177654...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #4:
score: 0
Accepted
time: 86ms
memory: 11672kb
input:
599394 100000 683408 868635908987 347999512025 347999739145 740945 377178907084 399211757563 399211757568 766968 548821086083 630762 702128377806 756554924031 756554924036 904713771313 904714518208 17026878789 17027129255 11601638470 206412869961 253365321722 253365321730 785476956554 785477402085 2...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 lines
Test #5:
score: 0
Accepted
time: 38ms
memory: 5508kb
input:
255255 100000 693776785134 693776920782 174578728959 174578728960 109045569231 631173362385 470661333171 470661439492 401883 183360880923 436203696728 436203931780 165055 339075075373 640081 299360395352 864237441330 864237509663 730335563579 730335652091 194265481215 194265481219 40664920117 406649...
output:
48406 1 186110004314 37959 65357983202 83815 120861662355 106705381500 24327 31556 2 13697 28081 260202193146 52511483770 4 46174459075 3 175347987986 2 47909 258154440479 327427357801 2 22468 54932 46381156133 45666301683 94552873123 55243 2 152254920558 2 109713294365 91231052949 144890963440 1 19...
result:
ok 100000 lines
Test #6:
score: -100
Wrong Answer
time: 54ms
memory: 7380kb
input:
504735 100000 890566082557 890566082559 106681282682 350150954751 14542620333 14542688528 962703917051 962703917057 100450168807 730499846454 90869911943 879001649039 367411155928 367411237841 162790964603 162791319243 843464048636 843464048641 50183553762 50183754394 536413208571 536413208579 76470...
output:
3 91776653818 25745 4 237499194819 297088721196 30767 133683 4 75618 5 14803350036 102273946312 294367282076 90067 26374064222 218863908151 5920 116441 80585705578 78122672310 26247 4 2 362715381968 5 118998177006 1 46573605766 3 294440148616 16240766556 148286820503 170413778829 308538368031 80990 ...
result:
wrong answer 6346th lines differ - expected: '81960', found: '-4116442'