QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554696#8563. The Older We Are, The Worse It HurtsPhantomThreshold#AC ✓103ms93032kbC++202.0kb2024-09-09 14:39:542024-09-09 14:39:54

Judging History

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

  • [2024-09-09 14:39:54]
  • 评测
  • 测评结果:AC
  • 用时:103ms
  • 内存:93032kb
  • [2024-09-09 14:39:54]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;

const int maxn = 210000;

vector<int>E[maxn];
int n,m;
int a[maxn];
int fa[maxn],siz[maxn],sum[maxn];
int f[maxn],g[maxn];
struct node
{
    int a,b,i;
    friend inline bool operator <(const node &k1,const node &k2){ return k1.a*k2.b < k1.b*k2.a; }
};
void dfs(const int x)
{
    siz[x]=1;
    sum[x]=a[x];
    for(auto y:E[x]) if(y!=fa[x])
    {
        fa[y]=x;
        dfs(y);
        siz[x]+=siz[y];
        sum[x]+=sum[y];
    }

    f[x]=a[x];
    vector<node>V;
    for(auto y:E[x]) if(y!=fa[x])
    {
        V.push_back( (node){ siz[y],sum[y],y } );
        f[x]+=f[y];
    }
    sort(V.begin(),V.end());
    int num=1;
    for(auto k:V)
    {
        f[x]+=num*k.b;
        num+=k.a;
    }
}
ll ans;
void calc(const int x)
{
    vector<node>V;
    for(auto y:E[x])
    {
        if(y!=fa[x]) V.push_back( (node){ siz[y],sum[y],y } );
        else V.push_back( (node){ n-siz[x],m-sum[x],y } );
    }
    sort(V.begin(),V.end());

    int vn=(int)V.size();
    vector<int>rb(vn+1),la(vn+1);
    la[0]=1;
    for(int i=1;i<vn;i++) la[i]=la[i-1]+V[i-1].a;
    for(int i=vn-1;i>0;i--) rb[i-1]=rb[i]+V[i].b;
    
    ll temp=a[x],num=1;
    for(int i=0;i<vn;i++) 
    {
        temp+= num*V[i].b;
        num += V[i].a;

        int y=V[i].i;
        if( y!=fa[x] ) temp+= f[y];
        else temp+=g[x];
    }
    ans=min(ans,temp);

    for(int i=0;i<vn;i++) if(V[i].i!=fa[x])
    {
        int y=V[i].i;
        g[y]= temp-f[y]- V[i].a*rb[i] -V[i].b*la[i];
    }
    for(auto y:E[x]) if(y!=fa[x])
        calc(y);
}

signed main()
{
    ios_base::sync_with_stdio(false);

    cin>>n;
    for(int i=1;i<n;i++)
    {
        int x,y; cin>>x>>y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        m+=a[i];
    }
    dfs(1);
    ans=LLONG_MAX;
    calc(1);
    cout<<ans<<endl;

    return 0;
}

詳細信息

Test #1:

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

input:

3
1 2
1 3
1 2 3

output:

11

result:

ok 1 number(s): "11"

Test #2:

score: 0
Accepted
time: 1ms
memory: 11756kb

input:

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

output:

35

result:

ok 1 number(s): "35"

Test #3:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
88884 152575 143867 52702 129130 80884 102053 174444 90537 186376

output:

6260059

result:

ok 1 number(s): "6260059"

Test #4:

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

input:

100
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 53
5...

output:

475487509

result:

ok 1 number(s): "475487509"

Test #5:

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

input:

1000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 53
...

output:

49636485565

result:

ok 1 number(s): "49636485565"

Test #6:

score: 0
Accepted
time: 41ms
memory: 51820kb

input:

100000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 5...

output:

498631652789011

result:

ok 1 number(s): "498631652789011"

Test #7:

score: 0
Accepted
time: 76ms
memory: 93032kb

input:

200000
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 5...

output:

1998890674293756

result:

ok 1 number(s): "1998890674293756"

Test #8:

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

input:

10
1 7
1 8
2 3
3 10
4 7
5 8
6 10
8 9
8 10
82092 194867 56452 165409 46166 19439 102526 106912 189486 193684

output:

5407291

result:

ok 1 number(s): "5407291"

Test #9:

score: 0
Accepted
time: 1ms
memory: 9988kb

input:

100
1 40
1 54
1 78
2 82
3 99
4 56
5 44
5 87
5 94
6 82
7 62
8 38
8 63
8 97
9 28
9 75
10 39
10 72
10 100
11 15
11 21
12 55
12 71
12 87
13 26
14 68
14 82
14 88
15 26
15 62
16 42
17 18
18 90
19 43
20 63
22 58
23 56
23 66
23 79
24 69
25 62
26 47
26 93
26 97
27 39
27 77
28 29
29 36
30 37
31 80
32 72
33 66...

output:

421120037

result:

ok 1 number(s): "421120037"

Test #10:

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

input:

1000
1 222
1 630
1 818
2 7
2 366
3 213
3 282
3 596
4 212
5 317
6 745
7 67
8 560
8 931
9 84
9 184
9 305
9 306
10 417
10 547
11 29
12 704
12 830
13 524
14 399
14 629
15 129
15 644
15 954
16 418
17 170
18 434
19 85
20 28
20 943
21 296
21 523
22 745
23 355
24 235
24 383
25 93
25 656
25 720
25 886
26 363...

output:

47098913396

result:

ok 1 number(s): "47098913396"

Test #11:

score: 0
Accepted
time: 44ms
memory: 17884kb

input:

100000
1 9740
1 49654
2 193
2 42318
2 96874
3 8605
3 47963
4 59219
5 28490
5 95449
6 27660
6 41375
6 53022
6 66835
6 94567
7 83100
8 82829
8 92810
9 2458
10 21811
10 75721
11 315
11 20049
11 52226
12 68436
12 75710
13 9651
13 55769
13 95180
14 82763
15 24521
16 78612
17 20314
18 38963
19 13416
20 24...

output:

493827158811210

result:

ok 1 number(s): "493827158811210"

Test #12:

score: 0
Accepted
time: 101ms
memory: 25628kb

input:

200000
1 48334
1 88568
1 133870
2 14768
2 59558
2 94254
3 14901
4 92831
4 187383
5 38599
5 45343
5 194164
6 32244
7 61411
8 22440
8 163276
9 26602
9 168498
9 178984
10 72427
10 118896
11 16651
11 107281
11 186764
12 63295
12 91535
13 118330
14 26343
14 102327
15 25907
16 151791
17 54022
17 57434
17 ...

output:

1984469138449540

result:

ok 1 number(s): "1984469138449540"

Test #13:

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

input:

10
1 2
2 3
3 4
3 5
4 6
4 7
4 8
5 10
6 9
171640 34584 23999 84435 148970 128300 147950 199598 38545 7852

output:

4664621

result:

ok 1 number(s): "4664621"

Test #14:

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

input:

100
1 2
1 3
1 14
1 22
1 37
2 4
2 7
2 19
2 39
2 44
3 5
3 6
3 11
3 43
3 46
4 10
4 12
4 13
5 8
5 74
6 9
6 15
6 72
6 83
7 23
8 21
9 28
9 75
9 76
10 25
10 60
10 68
10 86
11 30
11 32
11 67
12 16
12 18
12 48
13 26
13 66
14 17
14 52
14 55
17 20
18 24
18 61
19 27
19 42
19 90
20 33
20 40
20 58
21 47
22 31
22 ...

output:

462902677

result:

ok 1 number(s): "462902677"

Test #15:

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

input:

1000
1 2
1 3
1 7
1 13
1 35
1 47
1 62
2 5
2 6
2 26
2 27
2 34
2 79
2 157
2 249
3 4
3 22
3 70
3 81
4 11
4 29
4 110
4 114
5 21
5 94
5 115
5 130
6 8
6 14
6 167
6 170
6 418
6 633
7 9
7 10
7 12
7 40
7 57
7 67
7 527
7 625
8 48
8 51
8 55
8 218
8 806
9 16
9 23
9 44
9 49
9 103
9 190
9 280
9 521
10 679
10 918
1...

output:

47786153869

result:

ok 1 number(s): "47786153869"

Test #16:

score: 0
Accepted
time: 35ms
memory: 19496kb

input:

100000
1 2
1 9
1 12
1 45
1 47
1 55
1 141
1 260
1 288
1 1464
1 1939
1 11365
1 12563
1 15186
2 3
2 4
2 6
2 7
2 39
2 626
2 662
2 842
2 960
2 1508
2 6362
2 12680
2 48653
3 8
3 49
3 222
3 275
3 535
3 3529
3 4060
3 7438
3 9624
3 11795
3 20087
3 25917
3 26664
3 27533
3 27675
3 51085
3 59699
3 86531
4 5
4 2...

output:

495558439961116

result:

ok 1 number(s): "495558439961116"

Test #17:

score: 0
Accepted
time: 95ms
memory: 25496kb

input:

200000
1 2
1 3
1 13
1 59
1 71
1 700
1 5290
1 14056
1 16467
1 134461
2 4
2 6
2 7
2 8
2 15
2 28
2 44
2 136
2 675
2 1027
2 4120
2 13293
2 23306
2 29130
2 36284
2 62147
2 103685
2 110696
2 173341
2 183297
2 199355
3 5
3 10
3 18
3 29
3 88
3 107
3 218
3 430
3 630
3 1871
3 3017
3 5031
3 5791
3 29073
4 49
4...

output:

1990649326000094

result:

ok 1 number(s): "1990649326000094"

Test #18:

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

input:

10
4 8
1 5
6 3
5 8
2 1
4 3
6 7
7 9
10 1
195748 38162 161841 14237 86925 34468 64592 144428 192111 192089

output:

5329275

result:

ok 1 number(s): "5329275"

Test #19:

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

input:

100
78 94
18 37
71 82
52 14
78 44
78 55
56 44
26 10
85 24
66 5
7 79
30 92
66 63
16 57
21 99
35 42
39 84
66 65
67 58
40 63
16 43
73 52
45 21
7 92
71 10
1 45
60 54
87 90
73 68
65 19
14 56
18 55
15 22
63 36
52 10
29 85
64 81
63 9
36 34
64 7
27 34
56 88
7 73
98 67
23 71
43 79
41 71
88 62
35 58
11 98
14 ...

output:

394355527

result:

ok 1 number(s): "394355527"

Test #20:

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

input:

1000
317 548
357 83
516 649
336 164
548 654
111 660
9 105
942 208
879 179
631 428
733 980
422 719
558 136
459 66
355 536
251 841
127 517
420 250
839 187
999 630
81 980
880 712
440 487
914 39
873 217
37 242
712 679
538 119
359 798
80 812
219 754
231 108
398 670
201 71
401 676
41 734
278 351
903 144
8...

output:

45755641914

result:

ok 1 number(s): "45755641914"

Test #21:

score: 0
Accepted
time: 48ms
memory: 19592kb

input:

100000
49582 39999
79391 18647
48656 38113
70334 79359
51699 83915
56760 31630
98156 4992
85784 45476
94679 31586
49468 85156
40654 61744
10358 90311
3928 52174
10419 95458
44210 76753
59400 93499
56022 19964
83989 68908
65255 40202
36332 7991
27857 40501
81480 99772
18439 29752
13903 67107
14163 86...

output:

495948428945363

result:

ok 1 number(s): "495948428945363"

Test #22:

score: 0
Accepted
time: 103ms
memory: 25468kb

input:

200000
189324 7548
22586 157240
11256 172490
150550 8046
76399 160223
43296 84504
58990 41278
65110 131557
35353 176219
163411 44179
31599 104298
10029 199391
184720 178656
45461 3467
59629 151067
123870 154897
35475 48185
155607 186516
60091 91122
53990 40261
39114 95313
101366 193391
51989 73037
7...

output:

1990392142747089

result:

ok 1 number(s): "1990392142747089"

Test #23:

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

input:

10
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
184191 10442 37144 58440 31340 61211 38611 56030 25638 6562

output:

1706054

result:

ok 1 number(s): "1706054"

Test #24:

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

input:

100
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 62...

output:

325041829

result:

ok 1 number(s): "325041829"

Test #25:

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

input:

1000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 6...

output:

35108520559

result:

ok 1 number(s): "35108520559"

Test #26:

score: 0
Accepted
time: 43ms
memory: 22908kb

input:

100000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

output:

332899024879542

result:

ok 1 number(s): "332899024879542"

Test #27:

score: 0
Accepted
time: 76ms
memory: 37588kb

input:

200000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

output:

1333650749992625

result:

ok 1 number(s): "1333650749992625"

Test #28:

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

input:

10
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
60278 55785 89416 125841 183820 45708 20539 104121 161392 68622

output:

3892413

result:

ok 1 number(s): "3892413"

Test #29:

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

input:

100
1 2
1 27
1 37
1 40
1 57
1 71
1 76
1 80
1 81
1 82
1 97
2 3
2 17
2 23
2 66
2 74
2 78
2 83
2 98
2 100
3 4
3 30
3 41
3 44
3 45
3 49
3 67
3 79
3 85
4 5
4 11
4 25
4 38
4 51
4 54
4 59
4 77
4 93
4 95
5 6
5 12
5 28
5 62
5 63
5 68
5 72
5 73
5 84
6 7
6 32
6 35
6 42
6 56
6 60
6 65
6 75
6 86
7 8
7 14
7 18
7 ...

output:

370368019

result:

ok 1 number(s): "370368019"

Test #30:

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

input:

1000
1 2
1 120
1 276
1 345
1 478
1 520
1 637
1 737
1 835
2 3
2 241
2 331
2 340
2 515
2 523
2 610
2 617
2 628
2 741
3 4
3 263
3 321
3 439
3 447
3 517
3 529
3 739
3 758
3 855
3 925
3 927
3 992
4 5
4 465
4 477
4 514
4 548
4 650
4 671
4 771
4 794
4 798
4 941
4 983
5 6
5 230
5 336
5 493
5 516
5 736
5 747...

output:

38124534486

result:

ok 1 number(s): "38124534486"

Test #31:

score: 0
Accepted
time: 46ms
memory: 25736kb

input:

100000
1 2
1 21369
1 27946
1 37693
1 40131
1 58368
1 59913
1 70232
1 76960
1 85521
1 88957
1 90017
1 95685
2 3
2 17663
2 22150
2 23260
2 30993
2 43517
2 70634
2 72336
2 87058
2 95892
2 95994
3 4
3 20682
3 25488
3 26051
3 27134
3 47846
3 48490
3 66920
3 72674
3 81577
3 81811
3 82695
3 87170
3 87500
3...

output:

386479015083602

result:

ok 1 number(s): "386479015083602"

Test #32:

score: 0
Accepted
time: 71ms
memory: 42360kb

input:

200000
1 2
1 20153
1 45368
1 62117
1 90434
1 100476
1 114441
1 164479
2 3
2 51438
2 69090
2 110663
2 121882
2 123540
2 125557
2 149485
2 151079
2 154761
2 172501
3 4
3 107025
3 131836
3 152176
4 5
4 34915
4 40352
4 93945
4 116509
4 132426
4 164896
4 182862
4 198856
4 199021
5 6
5 46175
5 66289
5 117...

output:

1548837807549665

result:

ok 1 number(s): "1548837807549665"

Test #33:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
67454 42805 183067 146613 138879 37619 3066 154041 185665 183608

output:

5599249

result:

ok 1 number(s): "5599249"

Test #34:

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

input:

100
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
2 52
2 53
2 54
2 55
2 56
2 57
2 58
2 59
2 60
2 61
2 62...

output:

349401494

result:

ok 1 number(s): "349401494"

Test #35:

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

input:

1000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 6...

output:

34432296741

result:

ok 1 number(s): "34432296741"

Test #36:

score: 0
Accepted
time: 39ms
memory: 18956kb

input:

100000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

output:

467733643130393

result:

ok 1 number(s): "467733643130393"

Test #37:

score: 0
Accepted
time: 72ms
memory: 26436kb

input:

200000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

output:

1871102743707964

result:

ok 1 number(s): "1871102743707964"

Test #38:

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

input:

100
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
2 21
3 22
3 23
3 24
3 25
3 26
3 27
3 28
3 29
3 30
3 31
4 32
4 33
4 34
4 35
4 36
4 37
4 38
4 39
4 40
4 41
5 42
5 43
5 44
5 45
5 46
5 47
5 48
5 49
5 50
5 51
6 52
6 53
6 54
6 55
6 56
6 57
6 58
6 59
6 60
6 61
7 62...

output:

448761507

result:

ok 1 number(s): "448761507"

Test #39:

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

input:

1000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1 6...

output:

44219741747

result:

ok 1 number(s): "44219741747"

Test #40:

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

input:

100000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

output:

488126848096724

result:

ok 1 number(s): "488126848096724"

Test #41:

score: 0
Accepted
time: 61ms
memory: 26344kb

input:

200000
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 61
1...

output:

1965030843762849

result:

ok 1 number(s): "1965030843762849"