QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748439#9631. Median ReplacementIllusionaryDominanceAC ✓1692ms6388kbC++204.4kb2024-11-14 20:24:092024-11-14 20:24:09

Judging History

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

  • [2024-11-14 20:24:09]
  • 评测
  • 测评结果:AC
  • 用时:1692ms
  • 内存:6388kb
  • [2024-11-14 20:24:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()

const int p = 1e9+7;
const int N = 155<<1;

int inv[N], ifac[N], val[N];
int fpow(int x, int y)
{
    int r=1;
    for(;y;y>>=1,x=(ll)x*x%p) if(y&1) r=(ll)r*x%p;
    return r;
}

struct node
{
    int a[N];
    int l[N], r[N];
    int m;
    void init(int *v, int M)
    {
        int i; m=M;
        for(int i=1;i<=m;++i) a[i]=v[i];
    }
    int F(ll n)
    {
        int i; int ans = 0, rr = 0;
        if (n<=m) return a[n];
        l[0]=1;r[m+1]=1;
	    for (i=1;i<m;i++) l[i]=(ll)l[i-1]*(n-i)%p;
	    for (i=m;i;i--) r[i]=(ll)r[i+1]*(n-i)%p;
	    for (i=1;i<=m;i++)
	    {
	    	if ((m^i)&1) rr=p-a[i]; else rr=a[i];
	    	ans=(ans+(ll)rr*ifac[i-1]%p*ifac[m-i]%p*l[i-1]%p*r[i+1])%p;
	    }
	    return ans;
    } 
} sum[N];

void init()
{
    ifac[0]=inv[1]=1;
	for (int i=2;i<=300;i++) inv[i]=p-(ll)p/i*inv[p%i]%p;
	for (int i=1;i<=300;i++) ifac[i]=(ll)ifac[i-1]*inv[i]%p;
    
    for(int k=0; k<=200; ++k)
    {
        val[0] = 0;
        for(int i=1;i<=k+3;++i) val[i]=(val[i-1]+fpow(i, k))%p;
        sum[k].init(val, k+3);
    }
}

int getsum(int k, ll l, ll r)
{
    return (sum[k].F(r) + (p -  sum[k].F(l-1))) % p;
}

struct Poly
{
    array<int, 155> coef;
    int k;
    Poly(int x) {fill(all(coef), 0); coef[0] = x; k = 0;}
    Poly() {fill(all(coef), 0); k = 0;}
    Poly operator + (const Poly &b) const
    {
        Poly ret(0); ret.k = max(k, b.k);
        for (int i = 0; i <= ret.k; ++i) ret.coef[i] = (coef[i] + b.coef[i]) % p;
        return ret;
    }
    Poly operator * (const int d) const 
    {
        Poly ret(0); ret.k = k;
        for (int i = 0; i <= ret.k; ++i) ret.coef[i] = ((ll)coef[i] * d) % p;
        return ret;
    }
    Poly shift() const 
    {
        Poly ret(0);
        ret.k = k + 1;
        for (int i = 1; i <= ret.k; ++i) ret.coef[i] = coef[i-1];
        return ret;
    }
    Poly get (int a1, int a2) const
    {
        return ((*this).shift() * a1) + (*this) * a2;  
    }
    int pos(int i) const { return coef[i]; }
};

int n;
int l[N], r[N];
Poly f[N][2][2][2], g;
void solve()
{
    cin >> n;
    int all=1;
    vector<int> num;
    for (int i=1; i<=n; ++i) cin>>l[i];
    for (int i=1; i<=n; ++i) cin>>r[i], num.push_back(l[i]), num.push_back(r[i]+1), all=(ll)all*(r[i]-l[i]+1)%p;
    
    sort(all(num));
    num.erase(unique(all(num)), num.end());
    
    int ans=(ll)all*(num[0]-1)%p;
    
    for (int _tmp = 0; _tmp < num.size() - 1; ++_tmp)
    {
    
    int L=num[_tmp], R=num[_tmp+1]-1;
    
    for (int ok=0; ok<2; ++ok)
    for (int a=0; a<2; ++a)
    for (int b=0; b<2; ++b)
        f[0][ok][a][b] = Poly(0);
    f[0][0][0][0] = Poly(1);
    
    for (int i=0; i<n; ++i)
    {
    for (int ok=0; ok<2; ++ok)
    for (int a=0; a<2; ++a)
    for (int b=0; b<2; ++b)
        f[i+1][ok][a][b] = Poly(0);
        
    for (int ok=0; ok<2; ++ok)
    for (int a=0; a<2; ++a)
    for (int b=0; b<2; ++b)
    for (int c=0; c<2; ++c)
    {
        if (c)
        {
            if(r[i+1] < L) continue;
            
            if (R <= r[i+1] && L >= l[i+1])
            {
                f[i+1][ok|(a+b+c>=2)][b][c] = f[i+1][ok|(a+b+c>=2)][b][c] + f[i][ok][a][b].get(p-1, r[i+1]+1);
            }
            else 
            {
                assert(l[i+1] > R);
                f[i+1][ok|(a+b+c>=2)][b][c] = f[i+1][ok|(a+b+c>=2)][b][c] + f[i][ok][a][b] * (r[i+1] - l[i+1] + 1);
            }
        }
        else
        {
            if (l[i+1] > R) continue;
            
            if (R <= r[i+1] && L >= l[i+1])
            {
                f[i+1][ok][b][c] = f[i+1][ok][b][c] + f[i][ok][a][b].get(1, p-l[i+1]);
            }
            else 
            {
                assert(r[i+1] < L);
                f[i+1][ok][b][c] = f[i+1][ok][b][c] + f[i][ok][a][b] * (r[i+1] - l[i+1] + 1);
            }
        }
    }
    }
    
    g = Poly(0);
    for (int a=0; a<2; ++a) for (int b=0; b<2; ++b) g = g + f[n][1][a][b];
    
    for(int i=0; i<155; ++i)
    {
        (ans += (ll)g.pos(i) * getsum(i, L, R) % p) %= p;
    }
    }
    
    cout << ans << "\n";
}

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    init();
     
    int T;
    cin >> T;
    while (T--) 
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5868kb

input:

10
5
5 1 4 3 2
14 2 5 3 2
5
4 5 1 2 3
13 7 1 2 3
5
5 2 5 3 1
10 2 12 3 2
5
5 5 3 1 5
57 5 3 1 5
5
2 2 3 3 5
4 5 4 4 5
5
4 5 3 5 3
13 7 3 5 3
5
5 1 4 2 3
14 3 4 2 3
5
1 2 5 4 5
2 8 5 7 5
5
1 1 3 5 1
8 2 3 8 1
5
4 4 4 2 3
5 10 5 2 3

output:

180
170
650
265
182
173
120
296
192
131

result:

ok 10 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 5836kb

input:

10
5
1 2 2 5 3
6 4 2 6 3
5
4 4 1 4 3
6 7 2 5 3
5
5 3 4 2 4
5 7 5 2 6
5
1 5 3 5 2
7 7 3 5 2
5
1 3 3 2 2
10 5 3 2 2
5
4 4 4 5 3
4 11 9 5 3
5
5 3 2 1 3
13 5 2 1 5
5
5 4 1 2 5
10 6 1 2 5
5
3 5 3 4 2
5 9 3 5 2
5
1 1 3 2 1
7 3 3 3 1

output:

120
230
144
110
110
289
324
89
140
122

result:

ok 10 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 6012kb

input:

10
5
3 1 3 4 4
9 1 3 10 4
5
1 1 3 1 1
9 1 3 3 1
5
5 1 2 3 1
74 1 2 3 1
5
2 5 5 3 4
5 6 8 3 4
5
2 1 3 4 5
2 4 6 4 5
5
2 4 2 1 3
2 11 3 2 3
5
1 5 4 4 2
1 14 6 6 2
5
4 1 3 5 1
9 2 4 5 1
5
4 1 2 4 4
6 1 6 4 4
5
3 2 5 3 5
8 8 5 3 5

output:

196
76
140
172
72
80
486
84
65
224

result:

ok 10 lines

Test #4:

score: 0
Accepted
time: 29ms
memory: 5792kb

input:

10
5
676437428 903889545 700650370 965758082 146716866
676437431 903889567 700650370 965758082 146716866
5
517457740 64600397 388618400 783268973 388618400
517457797 64600397 388618400 783268973 388618400
5
971452763 106948541 259878781 537741075 9504353
971452780 106948544 259878781 537741075 95043...

output:

157838571
539867046
711272106
123881231
497944943
9791579
539012259
963879245
315607794
495624077

result:

ok 10 lines

Test #5:

score: 0
Accepted
time: 33ms
memory: 5860kb

input:

10
5
462008700 417744555 925098328 70231697 547596413
462008735 417744555 925098328 70231697 547596413
5
294230630 403894618 294230635 403894620 403894617
294230638 403894620 294230635 403894620 403894617
5
757647830 757647826 757647828 184694646 161891480
757647839 757647827 757647830 184694646 161...

output:

713470735
905154643
458869425
477055327
633375786
349097981
980046476
478461437
573246310
810688575

result:

ok 10 lines

Test #6:

score: 0
Accepted
time: 13ms
memory: 5880kb

input:

10
150
7 1 8 8 2 3 8 2 1 3 2 10 9 7 3 9 4 5 4 5 10 7 9 9 9 3 4 7 10 8 5 3 5 1 8 4 1 2 7 9 10 9 1 7 4 7 6 8 7 6 6 7 4 5 10 8 7 10 2 8 1 4 9 2 9 3 9 6 2 2 7 7 10 8 4 10 4 1 7 3 3 5 4 3 9 7 4 1 8 1 4 4 2 7 5 4 9 6 5 8 6 4 8 7 4 6 8 8 2 9 8 3 10 9 2 4 6 10 2 8 9 1 6 6 7 8 8 7 8 8 8 3 4 6 3 8 10 10 10 3 ...

output:

8640
8000
9600
8100
9360
9900
9600
9960
9300
5560

result:

ok 10 lines

Test #7:

score: 0
Accepted
time: 16ms
memory: 5800kb

input:

10
150
5 4 2 6 6 9 4 8 4 9 2 5 4 7 5 4 2 1 10 10 6 5 10 2 5 8 4 2 10 4 10 8 4 1 4 1 6 3 2 4 1 10 10 1 9 7 7 4 7 6 9 2 4 5 2 6 2 9 10 6 6 8 7 7 1 9 1 7 5 3 4 9 5 2 3 2 10 2 9 3 1 3 7 9 8 3 7 2 2 8 8 5 2 4 8 4 10 10 2 1 10 8 10 3 7 1 6 9 9 7 8 1 9 3 7 6 4 9 1 2 7 8 4 8 6 7 4 2 7 3 9 5 6 6 1 1 9 6 3 6 ...

output:

5760
9600
6580
7680
5280
7200
8640
8000
5400
5040

result:

ok 10 lines

Test #8:

score: 0
Accepted
time: 16ms
memory: 6080kb

input:

10
150
1 1 7 5 2 6 5 9 10 2 5 9 10 10 9 5 2 2 8 7 2 10 9 5 10 4 4 10 3 1 3 8 5 8 3 5 9 4 2 1 4 1 3 2 5 4 4 7 10 2 7 10 9 9 1 1 2 4 7 2 1 4 2 4 5 1 6 6 6 5 10 3 7 5 7 7 7 4 3 3 3 5 3 9 9 8 5 7 5 5 1 5 1 5 7 2 1 8 7 7 7 3 8 6 7 8 4 5 10 7 5 7 4 8 7 2 6 6 7 6 2 1 6 6 8 9 3 9 2 7 9 1 2 1 7 7 4 3 3 1 4 3...

output:

8800
8100
5040
5580
9600
7200
6400
5184
7560
8640

result:

ok 10 lines

Test #9:

score: 0
Accepted
time: 1303ms
memory: 6172kb

input:

10
150
390717977 225426217 217154512 811659013 811659022 811659006 811659019 811658998 380139276 562680969 391897894 391897902 610662417 702576570 778349151 778349150 144611847 144611847 888681165 952726258 635003873 635003864 365476184 353032583 492888825 492888833 451690481 492888832 492888828 781...

output:

444384507
582048587
4116309
958927956
240831257
919504659
253033294
811573108
93791855
55056035

result:

ok 10 lines

Test #10:

score: 0
Accepted
time: 1308ms
memory: 5876kb

input:

10
150
639295555 548367354 795034024 795034022 966256461 795034026 795034019 795034024 795034024 236525600 236525591 236525601 702472531 628995729 702472534 409845953 409845958 430611099 965171120 216366412 173295815 311261799 311261793 113953747 830664527 290505090 830664533 273223393 617764565 273...

output:

937895614
451483826
722427169
185150800
218102505
102966546
445812982
11748745
363947119
423405610

result:

ok 10 lines

Test #11:

score: 0
Accepted
time: 20ms
memory: 5900kb

input:

10
3
544728022 153689801 431863569
962200031 220484001 642878600
3
421093150 239667044 200668081
921717358 939761114 474185560
3
517484553 194763387 57955343
815612679 384192788 271266363
3
214367561 759072795 528460561
303043703 861920493 583504876
3
143012658 242807202 110332706
980720465 65744848...

output:

293616219
48585431
362851773
192424288
936380090
286057574
444732014
660047559
2182519
70392946

result:

ok 10 lines

Test #12:

score: 0
Accepted
time: 20ms
memory: 6096kb

input:

10
3
298079042 283121490 717390320
437344567 909940091 774539057
3
235438777 376875054 584255176
478700356 640919350 964768573
3
504253873 213254989 281505721
790055054 369444342 899259056
3
242453813 574481027 433905467
604033969 874943153 488294451
3
155021502 321365687 394277313
588948932 3628728...

output:

658457380
752702154
881598439
284195799
542121898
669197146
513534536
764463052
817670155
823615527

result:

ok 10 lines

Test #13:

score: 0
Accepted
time: 20ms
memory: 5800kb

input:

10
3
277164454 177504386 630108854
815592583 817130094 966582180
3
553551886 526662439 221462453
877993210 612603746 809537190
3
169107669 114697789 9365466
566730568 727422421 814482341
3
773373879 420215722 106068835
868342918 919639071 445011274
3
785827099 88432369 496957960
847893274 886893130 ...

output:

461710583
414550512
334516230
388987842
533579032
470040652
305411016
722018199
415828227
836463369

result:

ok 10 lines

Test #14:

score: 0
Accepted
time: 16ms
memory: 6072kb

input:

10
3
802940830 180816657 739400517
866223617 790954548 859222671
3
319700485 420670621 20112496
848710888 862460339 119058099
3
570852685 257303395 22343287
968627558 669195733 23553532
3
772960648 19212766 491996184
918599736 605893944 555566188
3
601445601 101290141 337160285
665968569 606274511 8...

output:

49494813
830694683
945521224
293496959
293657772
321812024
438726817
205376054
845441105
110533117

result:

ok 10 lines

Test #15:

score: 0
Accepted
time: 20ms
memory: 6084kb

input:

10
3
115993273 597120648 886068528
721362023 618405041 901128755
3
684616276 385798500 452823159
885203911 544535789 682511433
3
616136314 31141818 241912255
828030263 209761597 509249219
3
334790687 771587111 334138763
557406637 803908718 907322782
3
116832581 153505687 37609451
883976815 459234532...

output:

747305720
941038555
57462918
748152292
250716967
976657098
857556760
824115560
380112870
174895205

result:

ok 10 lines

Test #16:

score: 0
Accepted
time: 62ms
memory: 5784kb

input:

10
7
404918898 292311647 631396922 706089372 4898185 154066652 86654812
803261286 973316302 717003179 797462316 600001001 750252153 244616894
10
253859357 738242986 419522759 102326522 553403220 460105736 155341224 312766161 586806247 147676006
778607664 878991494 845146711 677678023 915736076 57019...

output:

849134175
306713685
881527929
251671699
694452876
311001344
628555523
346587535
902942159
103821021

result:

ok 10 lines

Test #17:

score: 0
Accepted
time: 52ms
memory: 5784kb

input:

10
7
121111846 445340255 191941417 423275256 868126532 333767818 25022569
260853257 809478517 266094588 686280489 934489058 456034373 948948371
7
301110391 272236238 727134768 371870131 919766596 151622847 242954800
358031962 617845183 850880394 555542716 925523610 266646892 265133857
7
539967256 15...

output:

497125921
258253342
380704069
786019436
912261795
632500387
250869698
544524402
415934297
985785773

result:

ok 10 lines

Test #18:

score: 0
Accepted
time: 62ms
memory: 5876kb

input:

10
9
207858087 631694427 287886898 358182369 613992517 796728947 498835939 435131275 390639390
775917322 791575481 548422068 549231678 900712002 989988795 625864644 894221883 889007873
7
292127639 293563569 94414926 757026897 216093287 54668573 659126092
585405226 551240378 279162638 958909562 78949...

output:

215421667
614451181
77960994
266883019
108364173
970035897
743934096
768983378
86008080
584393526

result:

ok 10 lines

Test #19:

score: 0
Accepted
time: 64ms
memory: 5872kb

input:

10
8
30947596 383236048 143686783 309066197 536154193 5357155 76140165 744480193
727145099 507226631 497967471 523313738 779787626 264931916 269289614 882809271
9
40989614 631023222 328430419 26599364 180448969 683186487 806322666 160679452 499905995
131736654 735260968 391251944 511881433 791591704...

output:

942880522
623635592
885310284
44833726
869194242
904636919
998102640
520298689
554134728
321585202

result:

ok 10 lines

Test #20:

score: 0
Accepted
time: 58ms
memory: 5856kb

input:

10
7
527148962 715399291 137919183 531321136 50973907 95271028 254976744
825165194 980761753 372939195 981935096 168277555 246414642 635564167
7
101659477 797868142 700786608 2398186 482053627 267841983 47067041
218316683 997740323 756305919 260795527 886244499 427633956 260347782
8
389457848 115128...

output:

685565542
812084335
379192186
811781184
613700870
107574211
758326954
457925630
213735319
69350931

result:

ok 10 lines

Test #21:

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

input:

10
149
1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 2 1 1 2 2 1 1 1 1 1 2 2 1 1 1 2 2 1 1 1 2 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 2 1 1 2 2 2 2 1 1 1 1 1 2 2 1 1 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 2 2 1 1...

output:

635008130
124160285
540032506
80065005
270016253
562080146
317504065
248320570
986564553
317504065

result:

ok 10 lines

Test #22:

score: 0
Accepted
time: 13ms
memory: 5864kb

input:

10
149
1 1 1 1 1 2 1 2 1 1 2 1 2 2 2 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 1 2 1 2 1 2 2 1 2 2 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 2 1 2 1 2 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 2 2 1 1 1 2 1 1 2 2 2 2 1 2 1 1 1 2 2 1 1 1 1 2 2 1 1 1 1 1 2 2 1 1 1 1 2 2 1 1 2 2 1 1 1 1 1 1 2 2 1 1 1...

output:

80065005
582344008
281040073
993282280
540032506
248320570
993282280
160130010
785032743
317504065

result:

ok 10 lines

Test #23:

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

input:

10
148
2 2 2 1 1 2 2 2 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 1 1 1 2 1 2 2 2 1 2 2 1 1 1 1 1 1 1 2 2 1 2 1 2 1 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 2 1 2 2 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 2 1 1 1 2 1 1 2 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 2...

output:

160130010
562080146
320260020
248320570
281040073
329376018
635008130
160130010
160130010
80065005

result:

ok 10 lines

Test #24:

score: 0
Accepted
time: 13ms
memory: 6048kb

input:

10
148
1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 2 2 1 2 1 1 2 1 2 1 1 1 1 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 2 1 1 1 2 2 1 1 2 2 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 1 2 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 2...

output:

80065005
946258191
164688009
946258191
640520040
540032506
160130010
496641140
946258191
892516375

result:

ok 10 lines

Test #25:

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

input:

10
148
1 1 1 1 1 2 1 1 2 1 1 2 1 1 2 2 1 2 1 1 1 1 2 2 2 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 2 2 1 1 1 1 1 1 2 2 1 1 1 1 2 1 1 2 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 2 2 2 1 2 2 1 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 2 1 1 2 1 1 2 2 1 1 1 2 2 2 2...

output:

496641140
320260020
986564553
993282280
270016253
658752036
270016253
329376018
993282280
993282280

result:

ok 10 lines

Test #26:

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

input:

10
150
752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752968683 752...

output:

726708573
915419289
85145284
579300071
537665168
366473149
561290774
793806849
611890051
614402417

result:

ok 10 lines

Test #27:

score: 0
Accepted
time: 13ms
memory: 5796kb

input:

10
150
319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319595269 319...

output:

388589272
602346764
462537146
60202120
320843890
351814258
42233160
712110504
611906201
377499089

result:

ok 10 lines

Test #28:

score: 0
Accepted
time: 16ms
memory: 6324kb

input:

10
147
86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492274 86492...

output:

768622775
683829672
830294274
581780613
343038002
920705863
13282476
26292105
317688586
363705467

result:

ok 10 lines

Test #29:

score: 0
Accepted
time: 16ms
memory: 6192kb

input:

10
149
322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322038482 322...

output:

729883852
742836494
375525630
921641879
871647658
955516173
697036547
96409123
321760629
870226465

result:

ok 10 lines

Test #30:

score: 0
Accepted
time: 16ms
memory: 5816kb

input:

10
149
254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254944881 254...

output:

598767342
925587638
691164677
840186622
93510386
361124370
918981547
358852426
152412885
63135715

result:

ok 10 lines

Test #31:

score: 0
Accepted
time: 16ms
memory: 6388kb

input:

10
148
303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303484245 303...

output:

494645000
102248666
116650840
202825805
881683198
70807294
85078744
509890856
124535818
321587476

result:

ok 10 lines

Test #32:

score: 0
Accepted
time: 16ms
memory: 6048kb

input:

10
150
67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433251 67433...

output:

844424406
219516167
108325299
602420453
909018124
182398298
129297636
550925302
989928501
230895797

result:

ok 10 lines

Test #33:

score: 0
Accepted
time: 1687ms
memory: 5800kb

input:

10
147
566148717 117031228 46015763 314994311 603135631 225980456 303552874 219843870 301970004 54574233 142459962 262415059 182837687 131567128 197386620 287794220 47113175 720054924 383821011 255651947 31786762 377370893 91536176 113937389 683483401 157998567 288284812 82724379 937975535 303995177...

output:

973175117
487609376
379373784
680113005
816631967
660582904
410286898
332733428
296751855
631972126

result:

ok 10 lines

Test #34:

score: 0
Accepted
time: 1681ms
memory: 5748kb

input:

10
150
796339229 316938933 425214771 166539603 824180283 232538460 255369633 333150819 78916114 230173375 9806346 73027060 565841043 256364645 738217979 157092616 95044594 262341668 836766900 237690355 191503586 73143696 899831471 945193270 210471765 50670052 190328033 226319101 233215545 32777192 1...

output:

384625613
22143057
863482289
783744983
423193302
584023436
504962547
666315361
778359886
417006573

result:

ok 10 lines

Test #35:

score: 0
Accepted
time: 1656ms
memory: 6020kb

input:

10
149
31564613 164771328 675762372 846108683 566066924 412881709 391062829 279128060 285596748 434189830 387989985 58071647 606384076 122719286 277522861 111163516 22596314 795203286 682233936 684917037 491914387 367175668 282143472 502680474 621648055 533284069 772618606 410134612 342199060 151868...

output:

456093840
646738907
890767382
910411032
961691504
938971378
284409611
217770931
877004542
578572688

result:

ok 10 lines

Test #36:

score: 0
Accepted
time: 1661ms
memory: 5884kb

input:

10
149
114678942 602915804 232306230 141185600 105295954 554009424 274899312 86038482 74085042 269953136 29227558 525406578 272279552 122945638 140546316 611165741 417972930 50104307 81900617 153394508 280800689 418115334 215485520 84291607 213738579 327541510 543022581 39117917 622864035 772843104 ...

output:

888753659
844718055
547717001
585353331
775201349
428390996
270637807
745658751
400609726
207301409

result:

ok 10 lines

Test #37:

score: 0
Accepted
time: 1692ms
memory: 5900kb

input:

10
149
923711646 221402961 212303466 92046091 569927886 112970908 810435285 295152719 528742511 19419419 191587556 437757191 389214680 173864261 361033830 289709096 24163550 759219115 340368674 158768671 406720039 340157349 479484710 449004308 125230031 543505632 217851926 126001217 825522967 118160...

output:

655834270
788444449
990479513
957056287
155100035
786138841
923014188
679077348
154880933
812372499

result:

ok 10 lines

Test #38:

score: 0
Accepted
time: 1664ms
memory: 5864kb

input:

10
148
363177220 208260877 54995600 263890391 306910162 196605368 208296453 543446020 223703172 351939733 268515978 551130801 661789465 227975726 495322812 220160916 404698 611268288 121412807 577018214 491068853 448006910 519115104 345974310 326859650 467592305 529597390 538015262 200041063 4464858...

output:

15667886
65171559
866260864
163498304
347840191
246211906
616827706
459472527
219382802
359650429

result:

ok 10 lines

Test #39:

score: 0
Accepted
time: 1690ms
memory: 6048kb

input:

10
150
340725014 782888912 7780868 249414347 923754769 521483020 33784318 484579995 151863075 373368233 507688435 688123654 162738460 835892896 371014947 122189411 89874794 52780591 660744174 6053566 18395801 205325598 501650106 144821510 213636777 151512440 145911819 667063702 627463463 527000125 7...

output:

251373320
836802256
82293689
626157787
599232387
47682392
625366306
74185042
245373142
792405877

result:

ok 10 lines