QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#200019#7351. Coprime Querieswhsyhyyh#AC ✓1089ms106424kbC++144.0kb2023-10-04 15:06:252023-10-04 15:06:26

Judging History

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

  • [2023-10-04 15:06:26]
  • 评测
  • 测评结果:AC
  • 用时:1089ms
  • 内存:106424kb
  • [2023-10-04 15:06:25]
  • 提交

answer

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize(3)

#include<bits/stdc++.h>
using namespace std;
#define vi vector<int >
const int N = 1e5+9;
int n,q,a[N],A[N],num,cnt;
vi b[N];
map<vi ,int >mp;
int rt[N];
struct seg{int ch[2],sum;}t[N*70];
void pushup(int c){
    t[c].sum=t[t[c].ch[0]].sum+t[t[c].ch[1]].sum;return ;
}
void modify(int &c,int l,int r,int x,int y){
    if(!c) c=++cnt;
    if(l==r){t[c].sum+=y;return ;}
    int mid=(l+r)>>1;
    if(x<=mid) modify(t[c].ch[0],l,mid,x,y);
    if(x>mid) modify(t[c].ch[1],mid+1,r,x,y);
    pushup(c);return ;
}
int query(int c,int l,int r,int x,int y){
    if(!c) return 0;
    if(x<=l&&r<=y) return t[c].sum;
    int mid=(l+r)>>1,ans=0;
    if(x<=mid) ans+=query(t[c].ch[0],l,mid,x,y);
    if(y>mid) ans+=query(t[c].ch[1],mid+1,r,x,y);
    return ans;
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
struct qq{int l,r,x,id,ans;}Q[N];
bool cmp(qq x,qq y){return x.r<y.r;}
#define pi pair<int ,int >
#define fi first
#define se second
#define mcp make_pair
vector<pi >p[N];
int que(vi c,int l,int r){
    if(l==r) return l;
    int ans=0,mid=(l+r)>>1;
    for(int i=0;i<c.size();i++) ans+=t[t[c[i]].ch[1]].sum;
    if(ans>0){  
        for(int i=0;i<c.size();i++) c[i]=t[c[i]].ch[1];
        return que(c,mid+1,r);
    }
    for(int i=0;i<c.size();i++) c[i]=t[c[i]].ch[0];
    return que(c,l,mid);
}
bool cmpp(qq x,qq y){return x.id<y.id;}

int main(){
    num=0,cnt=0;vi v;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);A[i]=a[i];
        for(int j=2;j*j<=a[i];j++)
            if(a[i]%j==0){
                while(a[i]%j==0) a[i]/=j;
                b[i].push_back(j);
            }
        if(a[i]!=1) b[i].push_back(a[i]);
        for(int k=0;k<(1<<(int)b[i].size());k++){
            v.clear();
            for(int j=0;j<b[i].size();j++)
                if((k>>j)&1) v.push_back(b[i][j]);
            if(!mp[v]) mp[v]=++num;
            int x=mp[v],y=((int)v.size()%2==0?1:(-1));
            // modify(rt[x],1,n,i,y);
            p[i].push_back(mcp(x,y));
        }
    }
    for(int i=1;i<=q;i++){
        scanf("%d%d%d",&Q[i].l,&Q[i].r,&Q[i].x);
        Q[i].id=i;
    }
    sort(Q+1,Q+q+1,cmp);

    int o=0;
    vi u,z;
    for(int k=1;k<=q;k++){
        int l=Q[k].l,r=Q[k].r,x=Q[k].x,X;X=x;
        while(o<r){
            ++o;
            for(int i=0;i<p[o].size();i++) modify(rt[p[o][i].fi],1,n,o,p[o][i].se);
        }
        v.clear();
        for(int j=2;j*j<=x;j++)
            if(x%j==0){
                while(x%j==0) x/=j;
                v.push_back(j);
            }
        if(x!=1) v.push_back(x);
        int ans=0;z.clear();
        for(int i=0;i<(1<<(int)v.size());i++){
            u.clear();
            for(int j=0;j<v.size();j++)
                if((i>>j)&1) u.push_back(v[j]);
            if(mp[u]){
                ans+=query(rt[mp[u]],1,n,l,r);
                z.push_back(rt[mp[u]]);
            }
        }
        if(ans==0) Q[k].ans=-1;
        else if(gcd(A[r],X)==1) Q[k].ans=r;
        else{
            // int R=r;r-=1,ans=r;
            // while(l<=r){
            //     int mid=(l+r)>>1;
            //     int sum=0;
            //     for(int i=0;i<(1<<(int)v.size());i++){
            //         u.clear();
            //         for(int j=0;j<v.size();j++)
            //             if((i>>j)&1) u.push_back(v[j]);
            //         if(mp[u]){
            //             sum+=query(rt[mp[u]],1,n,mid,R);
            //         }
            //     }
            //     if(sum) l=mid+1,ans=mid;
            //     else r=mid-1;
            // }
            Q[k].ans=que(z,1,n);
        }
    }
    sort(Q+1,Q+q+1,cmpp);
    for(int i=1;i<=q;i++) printf("%d\n",Q[i].ans);
    return 0;
}
//减少定义,卡时 
/*
5 4
1 2 3 4 6
1 5 2
1 1 1
4 5 2
3 5 3 
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 4
1 2 3 4 6
1 5 2
1 1 1
4 5 2
3 5 3

output:

3
1
-1
4

result:

ok 4 number(s): "3 1 -1 4"

Test #2:

score: 0
Accepted
time: 3ms
memory: 11224kb

input:

5 5
231 35 385 30 385
5 5 110
1 2 6
3 3 22
2 5 1155
2 3 35

output:

-1
2
-1
-1
-1

result:

ok 5 number(s): "-1 2 -1 -1 -1"

Test #3:

score: 0
Accepted
time: 3ms
memory: 10784kb

input:

5 5
88560 87945 59901 99630 83517
5 5 55350
1 5 64452
3 4 81549
2 4 77121
2 4 45756

output:

-1
-1
-1
-1
-1

result:

ok 5 number(s): "-1 -1 -1 -1 -1"

Test #4:

score: 0
Accepted
time: 3ms
memory: 11384kb

input:

100 100
21 21 105 10 231 10 2310 210 385 385 77 66 154 165 77 10 55 33 231 35 770 42 42 42 2310 14 77 21 70 770 42 35 462 231 15 770 385 22 10 105 110 770 6 385 66 6 770 105 462 77 55 22 6 35 462 770 15 6 462 42 210 22 105 154 30 2310 30 42 14 14 70 154 30 6 231 70 10 22 770 14 385 70 154 2310 77 33...

output:

-1
-1
80
-1
-1
26
-1
94
74
-1
57
18
-1
-1
70
38
-1
18
-1
-1
39
-1
85
-1
-1
62
32
51
16
78
53
-1
58
74
-1
-1
-1
78
28
-1
-1
-1
70
51
89
-1
63
80
62
46
-1
54
20
-1
63
94
-1
94
100
-1
-1
85
38
95
74
17
-1
62
-1
57
-1
-1
63
-1
-1
35
-1
-1
63
89
70
95
-1
-1
-1
91
91
-1
97
78
17
-1
-1
-1
51
94
50
50
-1
-1

result:

ok 100 numbers

Test #5:

score: 0
Accepted
time: 6ms
memory: 11300kb

input:

1000 1000
110 2310 1155 15 15 6 77 66 770 165 110 14 22 21 30 6 55 462 70 231 165 231 15 66 33 14 21 70 770 55 66 154 6 385 154 231 110 165 42 1155 6 33 14 6 385 30 15 70 70 55 462 30 105 10 2310 33 77 154 42 70 231 1155 15 14 110 105 330 770 462 2310 10 210 22 42 66 1155 33 231 1155 14 55 385 55 30...

output:

-1
728
-1
-1
799
-1
-1
425
774
487
835
914
-1
669
913
-1
647
869
509
854
666
-1
357
596
933
-1
755
711
-1
236
172
690
884
605
774
725
945
-1
668
-1
581
405
550
196
761
101
-1
-1
169
595
341
-1
802
687
-1
716
869
544
-1
-1
-1
-1
757
660
280
-1
-1
-1
829
584
-1
-1
139
669
641
874
-1
811
73
-1
-1
913
-...

result:

ok 1000 numbers

Test #6:

score: 0
Accepted
time: 0ms
memory: 13204kb

input:

1 10
14
1 1 70
1 1 165
1 1 35
1 1 66
1 1 30
1 1 462
1 1 70
1 1 231
1 1 1155
1 1 2310

output:

-1
1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 50ms
memory: 12952kb

input:

1 100000
15
1 1 1155
1 1 385
1 1 462
1 1 30
1 1 210
1 1 231
1 1 6
1 1 77
1 1 1155
1 1 33
1 1 1155
1 1 210
1 1 330
1 1 385
1 1 66
1 1 22
1 1 77
1 1 462
1 1 14
1 1 770
1 1 231
1 1 30
1 1 330
1 1 55
1 1 14
1 1 35
1 1 66
1 1 66
1 1 22
1 1 330
1 1 770
1 1 42
1 1 70
1 1 22
1 1 770
1 1 66
1 1 55
1 1 21
1 1...

output:

-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
1
-1
1
-1
-1
-1
-1
-1
1
-1
-1
-1
1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
1
-1
1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
1
-1
-1
1
1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 36ms
memory: 16196kb

input:

10000 10000
14 165 231 231 231 6 21 2310 70 35 10 10 10 462 165 14 35 462 110 105 105 770 154 231 70 70 21 385 2310 105 10 2310 66 6 2310 22 33 70 55 77 385 42 22 35 330 1155 462 22 231 462 15 21 35 21 231 22 462 42 14 385 210 2310 165 55 1155 210 22 66 110 2310 33 2310 165 21 330 154 66 42 21 385 2...

output:

5859
-1
6545
-1
8357
2695
6309
5412
5034
9457
9363
-1
9455
9663
5222
-1
9805
5525
1294
-1
4980
2007
9438
5313
7623
-1
9783
6745
1903
5711
6009
2742
1887
6999
3186
-1
-1
6166
9460
3675
3421
9289
6449
6925
8649
2711
9862
-1
8504
7438
7244
9059
-1
9449
7891
2556
5592
8273
-1
-1
5258
-1
7747
7107
9771
7...

result:

ok 10000 numbers

Test #9:

score: 0
Accepted
time: 510ms
memory: 57960kb

input:

100000 100000
6 462 231 10 42 33 210 21 165 231 330 154 330 77 10 66 10 55 1155 385 462 30 165 1155 154 22 770 66 30 105 10 385 15 33 770 77 165 66 66 165 110 110 770 15 77 35 22 10 1155 462 42 165 110 2310 22 30 2310 66 33 70 2310 1155 1155 165 21 385 462 15 231 21 55 231 330 70 22 2310 210 330 14 ...

output:

-1
68382
56540
62069
53256
91372
91471
92290
69783
65175
-1
-1
50608
62910
88412
-1
-1
75467
5889
-1
-1
85949
89840
89125
-1
60439
68835
86534
90011
78277
62214
65634
-1
-1
58476
-1
41220
98031
-1
72455
-1
-1
23432
85729
39778
73812
49011
-1
-1
84199
44719
-1
88636
55085
87493
91017
87411
35672
3220...

result:

ok 100000 numbers

Test #10:

score: 0
Accepted
time: 665ms
memory: 70712kb

input:

100000 100000
18468 41472 41148 37908 90720 95256 44388 57024 87804 51840 25596 6480 50220 35964 57672 44388 16848 36288 44064 67392 57024 82944 97524 89100 57024 27540 20088 24300 62208 52488 69984 86832 972 94932 85860 58320 81648 45036 78084 24300 94932 98820 80676 34344 22680 36612 62856 21708 7...

output:

77533
87593
87593
65504
35434
26396
98503
77533
87593
86924
87593
65504
98503
77533
60254
87593
64360
60254
84448
60254
84448
65504
84448
53238
86924
26396
86924
87593
-1
35434
45884
83077
53238
60254
98503
12422
60254
53238
77533
77533
98503
45884
35434
-1
12422
21695
26396
65504
64360
84448
65504
...

result:

ok 100000 numbers

Test #11:

score: 0
Accepted
time: 636ms
memory: 71628kb

input:

100000 100000
23976 66420 63504 63828 77436 7128 12312 48600 44388 71604 57348 91692 972 73872 11988 59292 44064 41472 29484 972 44712 45036 32400 39852 81000 16848 20088 84564 74196 62856 39204 86184 25920 9396 95580 64152 98172 324 34668 90396 46980 50868 80676 58644 98820 14580 51516 21384 13284 ...

output:

97877
91553
97877
31827
89348
55803
76979
76979
76979
70674
70674
31827
-1
30812
83888
-1
83888
84097
89348
70674
58733
76979
44528
-1
84097
65992
65992
84097
23413
65992
94180
51166
44528
65992
91553
76979
26432
56709
44528
97877
31827
8139
76979
31827
76979
89348
8139
-1
65992
76979
89348
65992
58...

result:

ok 100000 numbers

Test #12:

score: 0
Accepted
time: 662ms
memory: 71872kb

input:

100000 100000
27864 94284 89748 92340 65124 18468 84240 38556 2268 95256 86508 75816 54108 11988 64476 78408 68688 44388 17496 30456 31428 8100 64800 91692 8100 6480 22680 45360 87480 73224 9720 90720 49572 23328 4212 71280 11340 58320 87480 57672 1620 2916 78084 81324 76464 92664 40176 20736 47952 ...

output:

86673
57805
-1
54513
85697
86673
54513
78912
64885
54513
81611
92769
54513
78912
78912
88924
92769
88924
-1
70432
70432
83696
88924
88924
92769
70432
54513
85697
60271
61700
92769
5770
43812
24847
54513
17923
88924
70432
86673
47960
60271
92769
85697
81611
92769
61700
88924
64885
70432
88924
86673
6...

result:

ok 100000 numbers

Test #13:

score: 0
Accepted
time: 608ms
memory: 71012kb

input:

100000 100000
57996 69660 90072 25596 51840 18792 324 62208 37584 40176 54432 96228 3888 63828 92988 80676 41472 90396 67068 77436 70632 21708 1296 48924 13608 9720 5508 34668 30132 71280 40824 34668 92664 77436 90720 28188 61884 28512 89424 24300 42768 44064 34344 9396 76140 45036 54756 77760 972 6...

output:

-1
44806
-1
44806
-1
44806
44806
-1
-1
44806
44806
-1
-1
44806
44806
-1
-1
44806
-1
-1
-1
-1
-1
44806
-1
-1
-1
-1
44806
44806
-1
44806
44806
-1
44806
44806
44806
44806
44806
44806
-1
44806
44806
44806
-1
-1
44806
-1
44806
-1
44806
44806
44806
-1
-1
-1
44806
44806
44806
-1
-1
44806
-1
-1
-1
-1
44806
...

result:

ok 100000 numbers

Test #14:

score: 0
Accepted
time: 591ms
memory: 72196kb

input:

100000 100000
61884 96228 15228 54108 38556 31752 70956 54756 95580 63504 86184 79056 57024 3240 44388 99792 66096 91692 53784 11016 57024 84564 33696 972 36612 324 6804 94932 42120 82944 8748 34992 17820 91692 648 36936 74844 84888 42120 90396 97200 97200 31752 32400 53784 22032 43416 78408 37260 2...

output:

-1
-1
-1
8255
-1
-1
-1
-1
-1
-1
-1
-1
8255
8255
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
8255
8255
-1
-1
8255
8255
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
8255
-1
-1
-1
-1
-1
-1
8255
-1
-1
8255
8255
8255
-1
-1
-1
-1
-1
8255
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 100000 numbers

Test #15:

score: 0
Accepted
time: 612ms
memory: 70776kb

input:

100000 100000
66096 20088 41148 81324 24948 43092 40176 47628 52164 84564 15552 65772 9396 43740 96876 17496 93636 95580 40176 40500 45036 47952 64800 50220 64476 85860 8424 54432 55404 93636 79056 34344 41472 7452 9072 42768 90396 40500 94932 56700 51840 47952 29160 56376 28836 98496 33372 73872 71...

output:

-1
-1
24063
-1
24063
-1
-1
-1
-1
24063
-1
-1
-1
24063
-1
-1
-1
24063
-1
-1
24063
-1
-1
-1
-1
-1
24063
-1
-1
-1
-1
-1
-1
24063
-1
-1
-1
-1
24063
-1
-1
-1
-1
-1
-1
24063
-1
-1
24063
-1
-1
-1
24063
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
24063
24063
24063
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
24063
-1
-1
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 599ms
memory: 72684kb

input:

100000 100000
51840 34992 42120 34344 11664 80352 10692 46008 79704 26892 11988 26244 40176 42768 56376 41472 58968 60588 79056 82944 14580 6156 91692 52488 78408 2916 91044 70956 95580 972 20412 1296 44064 17496 43092 1944 77112 90072 66420 73548 69660 77760 45360 7128 20412 62856 972 66420 85212 4...

output:

-1
-1
-1
78028
78028
-1
-1
-1
-1
78028
-1
-1
-1
-1
-1
-1
-1
-1
-1
78028
78028
-1
-1
-1
78028
78028
-1
78028
-1
78028
-1
-1
-1
78028
78028
-1
78028
-1
-1
78028
-1
-1
-1
-1
-1
78028
-1
-1
-1
-1
78028
78028
-1
78028
-1
-1
-1
-1
-1
-1
78028
78028
-1
-1
-1
-1
-1
-1
78028
-1
-1
-1
-1
-1
-1
78028
-1
-1
-1
...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 579ms
memory: 71608kb

input:

100000 100000
59616 60264 68364 62856 96552 93312 82296 38556 38880 47628 43740 12960 92016 78084 9072 57672 83592 63180 67068 15228 972 67716 23976 4536 4212 92340 93636 30456 9072 10044 92016 4536 70308 34020 52812 8100 90072 45360 20736 39528 23004 27216 40176 32400 93636 42444 89424 65772 20088 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 571ms
memory: 70168kb

input:

100000 100000
63504 84240 92016 90072 84240 5184 50220 31104 94284 69984 72900 98172 47952 17496 60588 75492 9720 65772 53460 44388 86184 31104 58968 55080 29808 81972 93636 90720 22356 23328 58644 3888 94284 48276 59940 15228 4536 1944 73548 7128 76140 80352 40176 56700 68688 17820 76788 63828 5605...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 422ms
memory: 71440kb

input:

100000 100000
81648 21708 53784 4860 4212 36936 34020 75168 66420 80028 51192 81324 57672 67716 60264 25596 88128 48276 42120 15552 62532 33048 81324 52812 40500 16200 2916 40176 96228 26244 35640 9720 51192 31428 99468 56052 43416 43416 18468 72252 94932 54108 19764 96876 18468 99144 60588 61884 44...

output:

33649
-1
33649
33649
33649
-1
33649
33649
33649
33649
33649
33649
33649
33649
33649
33649
-1
33649
33649
33649
33649
33649
33649
33649
33649
33649
-1
-1
33649
33649
33649
-1
33649
33649
33649
-1
33649
-1
-1
33649
33649
33649
33649
-1
-1
-1
33649
33649
-1
-1
33649
33649
33649
33649
33649
33649
33649
...

result:

ok 100000 numbers

Test #20:

score: 0
Accepted
time: 353ms
memory: 71760kb

input:

100000 100000
84240 47952 78732 34668 89100 52488 2268 67716 24624 3888 80352 65772 11016 4536 11988 45684 15876 49896 28836 47304 51516 95904 13608 3240 64476 5832 2916 972 9720 36612 4860 11664 76464 46980 8100 60912 58968 1296 71280 38232 46008 4860 19764 19764 94608 77112 49248 61236 79380 42444...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 440ms
memory: 72096kb

input:

100000 100000
90720 70632 3888 61884 76788 64152 73872 60264 81000 22032 12312 51192 64476 43740 64476 62208 40500 53784 15552 78084 36936 55080 47304 55080 92664 93960 3240 61236 21708 48276 74196 13608 1620 61236 15228 68040 74520 56376 24300 4536 1944 54108 17172 45360 68040 56700 36612 59292 155...

output:

55501
55501
55501
55501
-1
55501
55501
55501
55501
55501
-1
-1
55501
55501
55501
55501
-1
55501
55501
-1
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
55501
-1
-1
-1
55501
55501
-1
55501
55501
55501
55501
55501
55501
55501
55501
55501
555...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 859ms
memory: 93012kb

input:

100000 100000
97674 41756 30587 93367 37814 56210 70591 76212 92856 72416 17374 50005 10001 52633 25769 48691 84461 72635 41975 68401 67598 43873 91250 43873 19418 74095 16498 43581 64897 41172 92418 68985 82928 24820 86432 89644 52341 69423 31244 18323 16936 29930 4015 31755 9198 62634 96433 65335 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 866ms
memory: 92240kb

input:

100000 100000
99864 80811 50662 89279 97747 11096 76285 28616 74387 67160 93002 62780 42194 85483 61758 41756 96360 21316 20367 58619 32631 63948 62123 39493 60955 38252 8103 56940 26499 65627 39128 64897 35624 27740 58692 18980 99791 2701 95484 32777 81176 90155 20221 93440 56137 54896 85775 95995 ...

output:

-1
90807
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
90807
-1
90807
-1
-1
-1
-1
90807
-1
-1
-1
90807
-1
90807
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
90807
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
90807
-1
-1
-1
-1
-1
-1
-1
90807
-1
-1
-1
-1
-1
-1
-1
-1
90807
-1
-1
-1
...

result:

ok 100000 numbers

Test #24:

score: 0
Accepted
time: 887ms
memory: 91576kb

input:

100000 100000
89060 57159 57743 10585 95046 41610 6205 93951 94316 11534 92856 12848 11826 31463 97747 21754 33726 69934 98696 24528 21827 70883 57159 35113 89352 2409 12775 70372 62707 14381 98842 86067 25550 68036 56283 97820 47304 10585 22557 97528 20075 26207 85994 17958 27302 84388 24747 13724 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #25:

score: 0
Accepted
time: 610ms
memory: 91624kb

input:

100000 100000
4672 43581 39347 98842 25331 11096 53217 85921 94316 76723 76869 4453 511 38033 84096 22265 45917 80957 26718 45260 32996 82052 76431 19126 16790 47888 60371 91469 79570 74168 29492 71978 3942 21389 35478 60225 55407 43143 43143 73584 52706 44384 16060 38763 47377 84388 8249 91104 1306...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #26:

score: 0
Accepted
time: 591ms
memory: 92472kb

input:

100000 100000
69496 45260 9052 57451 85337 41683 58911 51319 75847 34091 2117 17155 32704 46647 7081 64970 57889 42705 5110 48545 84826 2190 34237 14746 45260 62415 65043 4891 15841 35989 38836 30587 56502 48618 70372 26864 65554 51100 7519 25404 16936 17739 19199 25915 57013 76577 21827 8833 69350 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 614ms
memory: 92012kb

input:

100000 100000
71686 21681 16133 16060 45333 33799 26134 3650 33142 28835 77745 67160 2263 79497 5767 58035 32485 91323 83439 64021 87162 9125 29273 10366 49494 26572 94024 18323 14746 47377 35916 26499 46428 88841 81030 18907 50297 21681 71832 90228 55772 40661 98039 50370 4015 6205 60736 14162 365 ...

output:

80788
80788
80788
80788
80788
-1
80788
80788
-1
80788
-1
-1
-1
-1
-1
80788
80788
80788
80788
-1
80788
80788
-1
80788
-1
80788
80788
-1
80788
-1
80788
-1
80788
80788
80788
80788
80788
-1
-1
-1
80788
80788
-1
80788
-1
80788
80788
-1
80788
80788
-1
-1
-1
-1
-1
-1
80788
80788
-1
80788
-1
80788
-1
80788
...

result:

ok 100000 numbers

Test #28:

score: 0
Accepted
time: 604ms
memory: 91852kb

input:

100000 100000
73073 59933 25769 86286 52998 43362 52268 50954 90520 42413 66649 93221 54823 69496 26791 25477 2409 35040 73292 25988 47085 71394 53363 75701 365 86359 94754 30733 67087 40077 24090 11242 86797 44384 64386 60371 91104 74752 48472 26207 48253 30806 22922 81322 97601 50881 30222 36281 2...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #29:

score: 0
Accepted
time: 596ms
memory: 94228kb

input:

100000 100000
37960 36354 70153 44895 75628 11242 95192 3285 72051 37084 42340 6059 87089 2409 62780 5475 76942 96725 88987 29273 12045 78402 48472 8687 4599 50516 62196 81468 65992 51538 21170 69788 76796 84680 61977 52414 38544 45333 75482 28324 49786 53728 39128 43143 81906 80373 43800 91177 1861...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #30:

score: 0
Accepted
time: 619ms
memory: 92812kb

input:

100000 100000
40223 38033 39858 3504 73000 79132 25185 55553 29419 81395 18031 56064 19345 85556 98769 61247 88841 45406 67379 82125 1314 85337 6278 41610 70299 51976 91104 81760 2263 75993 30514 15330 79789 24966 59568 5986 23360 15914 2555 93148 27083 76650 42267 30295 28908 85702 82709 21973 4956...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 865ms
memory: 106424kb

input:

100000 100000
11258 59490 22064 84827 23119 95716 81385 45126 1601 77288 91761 70191 88270 73576 59561 37061 83511 21477 96532 61592 76516 72002 80890 35965 58365 73924 64265 66350 71795 50680 58383 31335 83541 59949 5506 59402 88507 30453 7416 85852 35615 55817 35919 51462 85407 31810 11174 19989 3...

output:

99996
99996
100000
99996
99998
99996
99996
99995
100000
99998
99995
99999
99995
99996
99996
100000
99997
99995
99996
99999
99997
99998
99997
99995
99996
99995
99996
99996
99995
99995
99995
99998
99996
99996
99996
99999
99996
99996
99996
99996
99996
99995
99996
99996
99996
99995
99996
99996
100000
99...

result:

ok 100000 numbers

Test #32:

score: 0
Accepted
time: 899ms
memory: 105584kb

input:

100000 100000
27387 84142 2618 47009 72373 74493 77560 61818 35757 14174 84905 29935 88360 10 21372 84978 31233 25932 27254 1641 72968 95587 88400 10349 4926 49540 25782 48107 29211 17847 77609 8902 1640 3381 7614 86707 23237 60528 94654 75963 8612 41227 34404 10108 43596 92894 25282 11529 71735 519...

output:

99996
99989
99996
99996
99997
99996
99994
99998
99995
99989
99989
99994
99996
99997
99998
99996
99989
99995
99996
99996
99999
99997
99996
99995
99989
99989
99989
99994
99989
99998
99997
99996
99989
99989
99995
100000
99989
100000
99996
99997
99986
99996
99996
100000
99996
99989
99998
99998
99989
999...

result:

ok 100000 numbers

Test #33:

score: 0
Accepted
time: 866ms
memory: 105608kb

input:

100000 100000
10811 283 40068 76486 88923 53269 82248 45806 69912 18356 45344 56975 21154 69547 91695 57087 35852 73490 57976 98586 36717 43365 71717 8924 18783 59749 20003 40264 43523 85013 88323 94980 11227 46814 33915 24411 57967 57899 14595 76473 24713 35150 185 9971 77592 86681 72093 35773 6235...

output:

99996
99998
99995
99998
99998
99997
99998
99998
99996
99994
99997
99998
99997
99996
99998
99998
100000
99996
99996
99998
99998
99995
99998
99997
99998
99996
99996
99998
99995
99998
99998
99996
99996
99995
99998
99998
99997
99998
99997
99995
99995
99995
99998
99996
99998
99995
99998
99997
100000
9999...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 1089ms
memory: 106108kb

input:

100000 100000
62414 54744 92587 35574 44343 99540 97397 10970 64715 41040 32017 70101 94540 35957 78940 56635 11761 23459 32291 73652 61442 64492 6507 22108 48157 12407 6700 76230 71924 31454 48113 13236 7405 25136 35097 57377 91136 10512 74201 37047 74397 90036 1464 17465 24323 52295 86930 53563 52...

output:

54129
77561
57067
62241
77757
86934
96711
55898
56436
51529
86226
65167
92867
69362
87386
73413
46254
58628
95609
78455
84138
42594
93592
99598
61117
85982
83818
74297
88519
54678
77404
58299
71284
6811
75586
70643
59289
98391
13272
66099
34421
87124
64833
85871
88610
87983
86240
74746
96721
83859
6...

result:

ok 100000 numbers

Test #35:

score: 0
Accepted
time: 1068ms
memory: 104888kb

input:

100000 100000
78542 3589 73140 21947 93596 2509 69380 27662 31574 77926 25161 29845 61927 29687 49263 4552 83675 71017 63013 37892 25190 12270 89824 63788 62014 55319 33625 1091 53533 98620 58827 99315 49696 1272 69910 19273 93162 40587 94143 2966 90498 75446 67245 51920 82512 46082 33742 77807 4326...

output:

69504
84982
48765
92684
70335
85544
44423
51828
87500
93271
36363
59365
34276
94233
56341
18877
36825
64184
92553
73670
15295
89501
22855
62546
81377
96666
87708
29165
91155
66328
89366
89591
89180
85371
90752
90312
35595
67225
73475
48178
63085
58162
90286
57138
87207
94909
63489
99623
86880
90361
...

result:

ok 100000 numbers

Test #36:

score: 0
Accepted
time: 1054ms
memory: 106280kb

input:

100000 100000
94670 19729 53694 51425 18658 48582 65556 78946 65730 49404 85601 56885 94721 31928 43778 52469 31398 75472 61031 10645 88939 3152 97334 62363 75871 65527 27846 82848 43653 65787 78053 9585 67795 44705 72019 89681 60596 3366 48677 60373 30790 93561 65730 86374 16509 7166 80553 69347 11...

output:

17376
92059
91293
77274
87108
79441
66903
62005
58099
67717
16489
86267
60675
45282
95584
97047
50948
76716
88566
81539
92377
97455
52493
64569
84430
77661
58957
93250
61086
49723
65222
88179
72043
63931
75008
87556
60000
70651
90574
77498
59046
50306
55431
35487
60387
84727
66395
86124
9738
72671
7...

result:

ok 100000 numbers