QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#792936#9597. Grade 2LoxilanteWA 415ms37528kbC++141.4kb2024-11-29 15:10:412024-11-29 15:10:43

Judging History

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

  • [2024-11-29 15:10:43]
  • 评测
  • 测评结果:WA
  • 用时:415ms
  • 内存:37528kb
  • [2024-11-29 15:10:41]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#define I(...) 0
#endif
const int U = 1e6+10;
vector<bool> v;
vector<int> sum{0};
signed main(void)
{
    #ifdef LOCAL
//	freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
//	freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
    #endif
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, n;
    cin>>x>>n;

    int t = 0;
    rep(i, 2, 5e6)
    {
        v.push_back(__gcd((i*x)^x, x) == 1);
        if (t)
        {
            if (v[i-2-t] != v[i-2]) t = 0;
            else if (v.size() == 2*t) break;
        }
        if (!t && v.back() == v[0]) t = i-2;
    }
    v.erase(v.begin()+v.size()/2, v.end());
    for(auto p: v) sum.push_back(p+(sum.empty() ? 0 : sum.back()));

    rep(i, 0, n)
    {
        int nl, nr;
        cin>>nl>>nr;
        cout<<sum.back()-sum[nl%v.size()]+sum[nr%v.size()+1]+(nr/v.size()-(nl+v.size()-1)/v.size())*sum.back()<<endl;
    }
    
    return 0;
}
/*
23 19 15 19 -9 19 15 19 23 -13 15 19 23 19 15 -13 kA+B
23 19 15 19 -9

51 -17 51 -17 51 -17

16-27
0 11
12 16 23
24 25 26 27
13 14 15 16
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

15 2
1 4
11 4514

output:

2
2252

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 348ms
memory: 36956kb

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: 414ms
memory: 37276kb

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: 386ms
memory: 37528kb

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: -100
Wrong Answer
time: 415ms
memory: 36636kb

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:

48309
1
186108349281
37857
65357402036
83799
120860587533
106704432584
24307
31592
2
13635
28037
260199879065
52511016758
6
46174048386
5
175346428545
4
47873
258152144650
327424445818
1
22424
54874
46380743735
45665895573
94552032220
55241
2
152253566498
2
109712318730
91230241644
144889674897
2
19...

result:

wrong answer 1st lines differ - expected: '48406', found: '48309'