QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#846791#8703. 天气预测Zaunese100 ✓894ms64140kbC++145.9kb2025-01-07 14:24:592025-01-07 14:25:04

Judging History

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

  • [2025-01-07 14:25:04]
  • 评测
  • 测评结果:100
  • 用时:894ms
  • 内存:64140kb
  • [2025-01-07 14:24:59]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<string>

#define fi first
#define se second
#define mkp std::make_pair
using llu=long long unsigned;
using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}

const int mod=998244353;
const int NV=2e5;

namespace poly{
    const int N=1<<19;
    int rev[N],wn[N],lim,invlim;
    int ksm(int a,int p){
        int ans=1;
        while(p){
            if(p&1) ans=(llu)ans*a%mod;
            a=(llu)a*a%mod;
            p>>=1;
        }return ans;
    }void init(int len){
        for(lim=1;lim<len;lim*=2);
        invlim=mod-(mod-1)/lim;
        for(int i=1;i<lim;++i) rev[i]=rev[i/2]/2|((i&1)*lim/2);
        for(int i=1;i<lim;i*=2){
            wn[i]=1;
            const int w=ksm(3,mod/i/2);
            for(int j=1;j<i;++j) wn[i+j]=(llu)wn[i+j-1]*w%mod;
        }
    }void DFT(int*a){
        static llu t[N];
        for(int i=0;i<lim;++i) t[i]=a[rev[i]];
        for(int i=1;i<lim;i*=2)
        for(int j=0;j<lim;j+=i*2)
        for(int k=0;k<i;++k){
            const llu x=t[i+j+k]*wn[i+k]%mod;
            t[i+j+k]=t[j+k]+mod-x;
            t[j+k]+=x;
        }
        for(int i=0;i<lim;++i) a[i]=t[i]%mod;
    }inline void IDFT(int*a){
        DFT(a);
        std::reverse(a+1,a+lim);
        for(int i=0;i<lim;++i) a[i]=(llu)a[i]*invlim%mod;
    }void cpy(int*a,int*b,int n){
        memcpy(a,b,sizeof*a*n);
        memset(a+n,0,sizeof*a*(lim-n));
    }
    using POLY=std::vector<int>;
    auto mul(POLY a,POLY b){
        static int A[N],B[N];
        const int N=a.size()+b.size()-1;
        init(N);
        cpy(A,a.data(),a.size());
        cpy(B,b.data(),b.size());
        DFT(A);
        DFT(B);
        for(int i=0;i<lim;++i) A[i]=(llu)A[i]*B[i]%mod;
        IDFT(A);
        return POLY(A,A+N);
    }
    std::vector<int> li;
    auto fzc(int l,int r){
        if(l+1==r) return POLY({mod+1-li[l],li[l]});
        int mid=l+r>>1;
        return mul(fzc(l,mid),fzc(mid,r));
    }auto get(const std::vector<int>&o){
        li=o;
        return fzc(0,o.size());
    }
}

int N,Q;

namespace seg{
    struct SEGT{
        int m,a;
    } tr[NV*26];
    int ls[NV*26],rs[NV*26],cnt,rt[NV+5];
    SEGT&operator+=(SEGT&x,const SEGT&y){
        x.a=((llu)x.a*y.m+y.a)%mod;
        x.m=(llu)x.m*y.m%mod;
        return x;
    }bool nleaf(int x){return ls[x];}
    void dn(int x){
        tr[ls[x]]+=tr[x];
        tr[rs[x]]+=tr[x];
        tr[x]={1,0};
    }void upd(int x,int l,int r,int ql,int qr,SEGT z){
        if(ql<=l&&r<=qr){
            tr[x]+=z;
            //printf("updend %d[%d,%d]%d %d\n",x,l,r,tr[x].m,tr[x].a);
            return;
        }
        int mid=l+r>>1;
        if(!ls[x]) ls[x]=++cnt;
        if(!rs[x]) rs[x]=++cnt;
        dn(x);
        if(ql<=mid) upd(ls[x],l,mid,ql,qr,z);
        if(mid<qr) upd(rs[x],mid+1,r,ql,qr,z);
    }void dfs(int x,int l,int r){
        if(!x) return;
        printf("%d[%d,%d]%d %d\n",x,l,r,tr[x].m,tr[x].a);
        if(!ls[x]){
            return;
        }
        int mid=l+r>>1;
        dn(x);
        dfs(ls[x],l,mid);
        dfs(rs[x],mid+1,r);
    }
}

namespace gph{
    std::vector<std::pair<int,int> > ques[NV+5];
    std::vector<int> G[NV+5];

    int merge(std::vector<int>&rts,poly::POLY p,int deg){
        if(rts.size()==1) return rts[0];
        auto mid=std::partition(rts.begin(),rts.end(),seg::nleaf);
        if(mid==rts.begin()) ++mid;
        std::vector<int> o(rts.end()-mid);
        for(auto i=mid;i!=rts.end();++i) o[i-mid]=seg::tr[*i].a;
        rts.resize(mid-rts.begin());
        const int r=rts[0];
        if(o.size()){
            if(deg<0){ // TODO
                seg::tr[r]+=seg::SEGT{0,1};
                return r;
            }
            p=poly::mul(p,poly::get(o));
            p.resize(deg+1);
        }
        const int rss=rts.size();
        if(deg>rss){
            p.erase(p.begin(),p.begin()+(deg-rss));
            deg=rss;
        }
        if(rts.size()==1){
            seg::tr[r]+=seg::SEGT{(p[deg]-p[deg-1]+mod)%mod,
                (mod+1-p[deg])%mod};
            return r;
        }
        for(int x:rts) seg::dn(x);
        auto sons=rts;
        for(int&x:sons) x=seg::ls[x];
        seg::ls[r]=merge(sons,p,deg);
        sons=rts;
        for(int&x:sons) x=seg::rs[x];
        seg::rs[r]=merge(sons,p,deg);
        return r;
    }int build(int x){
        ques[x].emplace_back(Q+1,0);
        int u=++seg::cnt;
        //printf("build %d\n",x);
        for(int i=0;i+1<(int)ques[x].size();++i){
            seg::upd(u,0,Q,ques[x][i].fi,ques[x][i+1].fi-1,
                    seg::SEGT{1,ques[x][i].se});
            //printf("%d,%d => %d\n",ques[x][i].fi,ques[x][i+1].fi-1, ques[x][i].se);
        }
        return u;
    }void dfs(int x){
        std::vector<int> rts;
        rts.push_back(build(x));
        //printf("raw %d=>%d\n",x,rts[0]);
        //seg::dfs(rts[0],0,Q);
        for(int t:G[x]){
            dfs(t);
            rts.push_back(seg::rt[t]);
        }
        int pos=rts.size()/2;
        poly::POLY tmp(pos+1,1);
        seg::rt[x]=merge(rts,tmp,pos);
        //printf("print %d=>%d\n",x,seg::rt[x]);
        //seg::dfs(seg::rt[x],0,Q);
    }
}

namespace xm{
    void print(int x,int l,int r){
        if(l==r){
            printf("%d\n",seg::tr[x].a);
        }else{
            int mid=l+r>>1;
            seg::dn(x);
            print(seg::ls[x],l,mid);
            print(seg::rs[x],mid+1,r);
        }
    }
    void _(){
        scanf("%d%d",&N,&Q);
        for(int i=2,p;i<=N;++i){
            scanf("%d",&p);
            gph::G[p].push_back(i);
        }for(int i=1;i<=N;++i){
            int x;
            scanf("%d",&x);
            gph::ques[i].emplace_back(0,x);
        }for(int i=1;i<=Q;++i){
            int x,y;
            scanf("%d%d",&x,&y);
            gph::ques[x].emplace_back(i,y);
        }
        gph::dfs(1);
        print(seg::rt[1],0,Q);
    }
}

int main(){
    xm::_();
    return 0;
}


详细

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 0ms
memory: 22716kb

input:

99 100
1 1 3 3 5 5 7 7 7 7 10 10 5 5 3 3 7 7 9 9 2 2 5 5 12 12 11 11 25 25 8 8 1 1 19 19 9 9 7 7 29 29 34 34 31 31 44 44 28 28 9 9 14 14 12 12 25 25 37 37 52 52 47 47 59 59 35 35 10 10 31 31 7 7 50 50 5 5 37 37 64 64 63 63 59 59 44 44 22 22 75 75 90 90 21 21 97 97
1 998244353 0 173041973 261455511 0...

output:

369498410
340301428
340301428
340301428
818250570
818250570
582814186
495589000
495589000
495589000
832775204
544932267
544932267
973379985
603834630
639346291
639346291
639346291
740840982
740840982
11776873
299072990
299072990
643290485
643290485
780724694
274914018
274914018
439117962
439117962
4...

result:

ok 101 numbers

Test #2:

score: 12
Accepted
time: 0ms
memory: 23652kb

input:

99 100
19 70 81 78 37 87 32 41 81 1 51 70 69 78 15 77 1 7 32 32 18 63 92 35 25 1 10 26 69 18 81 1 60 1 70 11 10 26 10 78 26 78 71 22 38 81 31 80 82 11 68 35 68 22 23 77 18 31 81 71 69 81 70 26 78 32 51 63 87 10 51 69 68 23 70 81 35 7 60 25 92 18 41 37 51 26 35 1 26 80 81 19 68 82 70 78 15 38
8469458...

output:

428244814
510533160
129507715
885061583
572657935
985072366
379262767
138504830
649419017
418455745
388969503
332508037
987908164
925068560
211309565
860587112
147832578
732985825
783166357
372053450
935348035
230461153
535115759
213482690
794049971
240025880
823373503
236792425
899371097
295636143
...

result:

ok 101 numbers

Test #3:

score: 12
Accepted
time: 0ms
memory: 22896kb

input:

99 100
23 46 8 41 40 43 43 52 13 41 17 50 74 1 15 61 52 1 76 73 74 15 7 53 91 15 73 62 22 76 91 15 41 11 43 46 41 67 48 1 7 15 52 46 61 14 15 92 73 98 43 49 43 46 41 73 43 62 52 67 11 40 50 55 48 22 48 12 23 49 22 91 41 76 23 8 55 23 15 53 98 43 17 92 48 12 76 15 89 1 22 89 14 13 14 14 91 43
8041012...

output:

361142660
365230506
904328048
336812265
770511159
784105929
2408672
166085969
784765927
136619370
767345952
705341930
2727349
592969737
145624071
655786225
290556554
381646839
814157883
370725508
750013496
902486256
265686605
872136534
890293862
374019071
516266124
445150632
694263226
728053514
5912...

result:

ok 101 numbers

Subtask #2:

score: 20
Accepted

Test #4:

score: 20
Accepted
time: 609ms
memory: 58300kb

input:

199999 50000
1 1 3 3 1 1 7 7 9 9 2 2 3 3 5 5 15 15 11 11 8 8 23 23 15 15 23 23 2 2 16 16 12 12 23 23 6 6 25 25 24 24 23 23 15 15 14 14 28 28 23 23 1 1 24 24 6 6 31 31 21 21 47 47 4 4 15 15 43 43 45 45 46 46 35 35 14 14 26 26 8 8 34 34 26 26 35 35 69 69 78 78 20 20 57 57 79 79 36 36 18 18 21 21 18 18...

output:

958227875
932169996
598799612
53627328
255190446
505984500
726445986
944211695
364601773
867632799
198331171
995503042
526487290
307800857
390094823
95968601
671395433
349799633
205968415
63541551
531733029
713234055
956810723
466175633
508840687
314880002
271439009
372143095
519045723
912560909
452...

result:

ok 50001 numbers

Test #5:

score: 20
Accepted
time: 607ms
memory: 58036kb

input:

199999 50000
1 1 3 3 3 3 1 1 1 1 9 9 1 1 3 3 17 17 16 16 15 15 18 18 5 5 19 19 24 24 14 14 19 19 5 5 37 37 33 33 18 18 35 35 24 24 38 38 5 5 7 7 2 2 6 6 7 7 56 56 13 13 3 3 34 34 24 24 3 3 62 62 53 53 10 10 41 41 45 45 75 75 79 79 21 21 85 85 27 27 31 31 16 16 42 42 72 72 16 16 84 84 26 26 105 105 9...

output:

497862503
124294660
397176378
994338425
592189640
582694334
330999356
142630828
51902965
568014727
609802320
567361977
997960225
359297070
580215422
300680570
710907948
416602899
445560241
751616830
105103171
625792481
476333230
733633325
503143337
310644436
732964975
255388231
672739100
14400954
69...

result:

ok 50001 numbers

Test #6:

score: 20
Accepted
time: 592ms
memory: 58024kb

input:

199999 50000
1 1 3 3 3 3 3 3 2 2 8 8 7 7 15 15 1 1 15 15 2 2 10 10 7 7 11 11 20 20 12 12 1 1 25 25 24 24 23 23 17 17 21 21 34 34 20 20 41 41 41 41 45 45 38 38 57 57 2 2 1 1 23 23 60 60 66 66 47 47 57 57 29 29 31 31 63 63 1 1 2 2 36 36 17 17 47 47 85 85 57 57 11 11 27 27 48 48 95 95 38 38 88 88 66 66...

output:

59341305
234159629
609344079
568914547
586098704
745910681
356996082
811890356
857293891
603284868
906665674
312284189
284249729
384492786
239069280
43635565
865803894
485905490
812189212
567364781
786615423
7210307
402636568
328079051
490971982
516649997
931760949
552962500
697476989
358140695
3672...

result:

ok 50001 numbers

Subtask #3:

score: 20
Accepted

Test #7:

score: 20
Accepted
time: 586ms
memory: 59844kb

input:

199999 50000
61948 108267 62334 187137 73931 128171 146929 515 59063 151584 168181 118250 154156 78613 150376 141031 153356 25507 91665 56550 74381 58980 196150 69373 28220 86497 83997 152674 10799 19541 178502 22696 129859 169734 189423 55294 60383 6307 58732 28821 131519 116542 60216 159381 76503 ...

output:

256430907
58358124
390150162
430393809
838988907
823861965
245891257
314111749
214578827
420801465
889256236
471146384
81007642
657936630
985796974
239152176
697225398
936151354
439761224
563460419
551309103
370934319
695905796
117444954
475683157
832042601
946476212
980777193
783734944
140540383
70...

result:

ok 50001 numbers

Test #8:

score: 20
Accepted
time: 576ms
memory: 59544kb

input:

199999 50000
131563 57736 79468 155533 10876 53666 133631 153321 81124 91860 68627 12079 158469 19047 96739 88887 109962 189448 15608 128108 37806 26874 107534 175334 68721 145773 158935 127058 148071 194863 40902 89738 50553 39157 121661 22623 181574 68280 1329 193189 57869 79914 57945 127010 14889...

output:

28585329
491632865
232264787
685183355
278117064
117140409
97499034
197958991
911355135
385173106
513788474
251450451
250515596
111485225
567967394
414219823
108237780
239083116
255465648
362148423
158171929
776697819
450869003
695779974
874969155
126983388
724061080
116947925
784795834
975023813
41...

result:

ok 50001 numbers

Test #9:

score: 20
Accepted
time: 575ms
memory: 59564kb

input:

199999 50000
45200 13523 181985 183538 166452 85999 134527 47475 72871 195278 135883 127003 22380 166550 180505 117448 170810 141024 20471 49999 189601 54910 14389 126992 32713 18863 164232 95054 127642 150914 172250 186575 66898 9069 46448 135213 55536 64972 7021 81770 50499 152131 187662 98604 193...

output:

157748594
554562246
511082125
202253489
53970961
903222635
551350083
867843376
745538107
447204866
375055707
919404699
804918658
870601426
581052417
684251141
857448342
135810932
945639061
864307830
650604589
389248187
299223902
927769525
634189364
619686266
646647154
933251868
253902183
919980678
8...

result:

ok 50001 numbers

Subtask #4:

score: 23
Accepted

Test #10:

score: 23
Accepted
time: 886ms
memory: 63944kb

input:

199999 50000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

836793342
398644200
538473237
207527576
23529262
836590067
589366956
422145168
247485022
825943836
727487193
435961156
658460261
245160473
114059086
987276150
713455239
40763976
437064352
858938272
658666248
325867212
225680431
818940949
35398398
305271396
324524364
146184818
924730014
788309254
328...

result:

ok 50001 numbers

Test #11:

score: 23
Accepted
time: 884ms
memory: 64140kb

input:

199999 50000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

143669108
392135228
272032604
190269198
969520645
29333662
960523309
114783947
919980481
435161951
426397443
684910791
453402615
297888660
672412203
873421593
972654481
167929065
422565595
686003972
980039018
278451003
495743948
516604835
789697622
305509325
601799147
268256955
734798831
176971086
6...

result:

ok 50001 numbers

Test #12:

score: 23
Accepted
time: 894ms
memory: 63968kb

input:

199999 50000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

277039708
44545963
375743538
43048293
817444850
212957954
990652202
55333625
213272345
128893971
885913700
408046727
235414837
836970003
963273237
627152441
143202927
954718912
56532720
971245119
924560590
92957203
800149262
198239317
68125805
289347776
788224202
866614081
460879594
756761837
225348...

result:

ok 50001 numbers

Subtask #5:

score: 25
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #13:

score: 25
Accepted
time: 5ms
memory: 23388kb

input:

999 1000
1 1 1 1 2 2 4 4 3 3 5 5 2 2 15 15 1 1 17 17 17 17 6 6 12 12 5 5 14 14 26 26 27 27 33 33 9 9 31 31 30 30 32 32 21 21 40 40 38 38 36 36 30 30 31 31 26 26 1 1 53 53 57 57 17 17 30 30 32 32 62 62 35 35 26 26 63 63 53 53 42 42 3 3 53 53 2 2 37 37 70 70 53 53 91 91 64 64 25 25 12 12 53 53 49 49 8...

output:

800998417
934499712
598135816
870153386
870153386
870153386
870153386
870153386
870153386
683102919
683102919
683102919
527618560
527618560
279638132
990357115
23946416
509003805
7935919
7935919
7935919
7935919
666851061
654243945
654243945
654243945
723684318
723684318
723684318
575102137
575102137...

result:

ok 1001 numbers

Test #14:

score: 25
Accepted
time: 725ms
memory: 57000kb

input:

199999 50000
112341 58088 26287 111958 182799 187282 58088 111958 111958 111958 24835 129152 187282 69504 163611 192301 24835 187282 90543 139747 112341 139747 174538 187282 26287 87631 139747 78699 129152 90155 90543 19247 13983 187282 111958 185038 1 79911 185590 78699 187282 58088 185590 152740 6...

output:

150164818
390266611
255705034
968130248
647683692
968602098
441076013
836159224
59525886
249816336
63623372
635660040
818517587
885757949
608597664
733285683
479462637
629263142
756587679
728497194
658225799
388379097
106017385
68609038
41202973
641351160
422531466
415231133
793799817
115845807
3905...

result:

ok 50001 numbers

Test #15:

score: 25
Accepted
time: 668ms
memory: 57356kb

input:

199999 50000
27158 168774 199171 144279 49095 10561 92884 120481 168578 88479 60405 92517 158850 165091 53047 113990 6973 124423 1772 135081 54194 176694 97952 147067 33656 25031 127449 153640 34650 12195 158205 190435 177446 100256 188273 48688 172457 48161 88195 126177 197010 46455 184323 25031 27...

output:

586251257
951789762
385069545
767070914
250456939
178541769
861181190
771175700
930312139
865073045
169313516
75310210
639953115
585636778
136314381
748069760
181907277
424395594
853559209
707129027
417063323
961744202
609112421
561591423
760792989
176730194
258473510
757022484
856762342
731760683
2...

result:

ok 50001 numbers

Test #16:

score: 25
Accepted
time: 889ms
memory: 63932kb

input:

199999 50000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

594772140
344991760
831850489
795203512
993784467
153623279
612548494
696662341
764319485
37553321
246421336
945492817
433929129
511373035
59447716
183720207
117141876
259878154
789719850
957196189
357026449
412593981
776657074
716565672
35493181
228999567
977029864
172752492
70816607
112324893
2585...

result:

ok 50001 numbers

Test #17:

score: 25
Accepted
time: 559ms
memory: 59540kb

input:

199999 50000
63791 146420 39482 28225 108863 118458 184020 101028 147676 55523 71931 155043 120114 173931 157917 132136 134098 30176 182942 183716 43910 79398 137627 82912 86504 163777 160131 1015 171862 31129 118842 142818 181596 14645 147745 26674 163539 115944 80765 156296 20499 3786 85561 116055...

output:

937999161
781910036
675395115
53609281
692429190
27508676
122283528
713513706
79291555
816893105
145138748
820130001
289999940
266907736
268375087
699056063
344726719
968797400
780052309
365077637
399658069
870545247
681316172
775493608
786787048
428836704
378680497
559318351
306014877
177014251
103...

result:

ok 50001 numbers

Test #18:

score: 25
Accepted
time: 586ms
memory: 58112kb

input:

199999 50000
1 1 3 3 2 2 2 2 3 3 9 9 3 3 10 10 17 17 10 10 11 11 2 2 12 12 25 25 11 11 15 15 33 33 30 30 37 37 23 23 12 12 12 12 17 17 41 41 17 17 31 31 16 16 43 43 49 49 50 50 46 46 50 50 13 13 51 51 68 68 28 28 36 36 62 62 26 26 35 35 23 23 16 16 74 74 1 1 5 5 52 52 83 83 87 87 36 36 36 36 36 36 8...

output:

951814818
259134271
794189609
604754973
457117291
436587386
416391255
950342369
756449745
464785130
774733929
202522080
422076912
921620227
826832402
907958123
831063915
847134054
241501846
489668727
458748303
917602580
286577518
218965332
42715631
764527954
879366367
7592277
418221345
469556845
140...

result:

ok 50001 numbers

Test #19:

score: 25
Accepted
time: 812ms
memory: 58008kb

input:

199999 50000
1715 90155 1715 1715 129152 129152 1 1715 1715 1715 1715 1715 129152 1 90155 1 129152 129152 1715 90155 129152 90155 1715 129152 1 90155 1 1 129152 1 129152 90155 1715 129152 90155 1715 1 1715 90155 1715 129152 90155 1 129152 90155 1715 1715 1 129152 1 90155 1 1715 129152 90155 1715 129...

output:

737817984
508008846
595987552
80373711
224809325
260861874
479895966
99672969
726653424
178610841
339898889
917536705
426405119
502433556
939101968
903920032
680529250
632715304
977094551
477581613
121944082
708467909
936448537
624027674
509037020
868431797
814696317
731736643
456337046
651129100
44...

result:

ok 50001 numbers