`
java-mans
  • 浏览: 11384422 次
文章分类
社区版块
存档分类
最新评论

Codeforces Round #104 (Div. 2) E Lucky Subsequence

 
阅读更多

迟到的ac,不错的题目,要预处理 n!mod 1000,000,007 和 n!对于 mod 1000,000,0007 的逆元,否则第22组数据的时候会超时!算 l乘到r mod p的时候只要算 r!mod p 再乘以 (l-1)! 对 mod p 的逆元,预处理复杂度O(n),查询复杂度O(1),是一个相当快速的方法!

至于那种 “分解素因子 + 二分幂取模 ” 的方法有没有这个快我不知道,但是编程的难度比较高,复杂度无从估计,所以这种方法才是王道!

#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<string>        
#include<cstring>
#include<cstdio>
using namespace std;
#define i64 __int64
const int mod=1000000007;
const int maxn=111111;

i64 f[maxn];
i64 dp[maxn];
i64 caca[maxn];
i64 nica[maxn];
char ss[maxn];
map<string,int>m;
map<string,int>::iterator mi;
int k,n,a,b;
string s;




bool lucky()
{
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!='4'&& s[i]!='7')
        {
            return false;
        }
    }
    return true;
}


void dpstart()
{
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=b;i++)
    {
        for(int j=i;j>=1;j--)
        {
            dp[j] += dp[j-1] * f[i];
            dp[j] %= mod;
        }
    }
    return ;
}

void exgcd(i64 t,i64 mm,i64 & x)
{
    while(t<0)
    {
        t+=mm;
    }
    t%=mm;
    if(t==1)
    {
        x=1;
        return ;
    }
    if(mm==1)
    {
        x=0;
        return ;
    }
    exgcd(t,mm%t,x);
    i64 temp=(t*x-1)/(mm%t);
    x += (mm/t)*temp;
    while(x<0)
    {
        x+=mm;
    }
    x%=mm;
    return ;
}

i64 ni(i64 t)
{
    i64 x;
    exgcd(t,mod,x);
    return x;
}

void init()
{
    caca[0]=1;
    nica[0]=1;
    for(int i=1;i<maxn;i++)
    {
        caca[i] = caca[i-1]*i;
        caca[i] %= mod;
        nica[i] = ni(caca[i]);
    }
    return ;
}

i64 ca(int l,int r)
{
    i64 temp=caca[r];
    temp *= nica[l-1];
    temp %=mod;
    return temp;
}

i64 cc(int x,int y)
{
    if(y==0)
    {
        return 1;
    }
    if(x==y)
    {
        return 1;
    }
    i64 up = ca(x-y+1,x);
    i64 down = ca(1,y);
    down = ni(down);
    up *= down;
    up %= mod;
    return up;
}

i64 final()
{
    i64 temp=0;
    for(int i=0;i<=k;i++)
    {
        if(a<i)
        {
            break;
        }
        temp += cc(a,i)*dp[k-i];
        temp %= mod;
    }
    return temp;
}


int main()
{
    init();
    while(cin>>n>>k)
    {
        m.clear();
        a=b=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%s",ss);
            s=ss;
            if(lucky())
            {
                if(m.find(s)!=m.end())
                {
                   m[s]++;
                }
                else
                {
                    m[s]=1;
                    b++;
                }
            }
            else
            {
                a++;
            }
        }
        int temp=1;
        for(mi=m.begin();mi!=m.end();mi++)
        {
            f[temp++]=mi->second;
        }
        dpstart();
        cout<<final()<<endl;
    }
    return 0;
}
→Judgement Protocol
Test: #1, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
3 2

10 10 10

Output
3

Answer
3

Checker Log
ok answer is 3

Test: #1, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
3 2

10 10 10

Output
3

Answer
3

Checker Log
ok answer is 3

Test: #2, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
4 2

4 4 7 7

Output
4

Answer
4

Checker Log
ok answer is 4

Test: #2, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
4 2

4 4 7 7

Output
4

Answer
4

Checker Log
ok answer is 4

Test: #3, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
7 4

1 2 3 4 5 6 7

Output
35

Answer
35

Checker Log
ok answer is 35

Test: #3, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
7 4

1 2 3 4 5 6 7

Output
35

Answer
35

Checker Log
ok answer is 35

Test: #4, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
7 4

7 7 7 7 7 7 7

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #4, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
7 4

7 7 7 7 7 7 7

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #5, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10 1

1 2 3 4 5 6 7 8 9 10

Output
10

Answer
10

Checker Log
ok answer is 10

Test: #5, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10 1

1 2 3 4 5 6 7 8 9 10

Output
10

Answer
10

Checker Log
ok answer is 10

Test: #6, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10 7

1 2 3 4 5 6 7 8 9 10

Output
120

Answer
120

Checker Log
ok answer is 120

Test: #6, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10 7

1 2 3 4 5 6 7 8 9 10

Output
120

Answer
120

Checker Log
ok answer is 120

Test: #7, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
20 7

1 4 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474

Output
29172

Answer
29172

Checker Log
ok answer is 29172

Test: #7, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
20 7

1 4 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474

Output
29172

Answer
29172

Checker Log
ok answer is 29172

Test: #8, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 20

940998996 995101329 411833571 790250028 789954091 11476964 616830669 993149037 419029224 285830508 167305004 936799270 984714909 91465930 533309926 858510423 841455703 524128555 299869821 99595306 593796701 999106695 317734732 701644338 570296686 ...
Output
926116413

Answer
926116413

Checker Log
ok answer is 926116413

Test: #8, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 20

940998996 995101329 411833571 790250028 789954091 11476964 616830669 993149037 419029224 285830508 167305004 936799270 984714909 91465930 533309926 858510423 841455703 524128555 299869821 99595306 593796701 999106695 317734732 701644338 570296686 ...
Output
926116413

Answer
926116413

Checker Log
ok answer is 926116413

Test: #9, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 2

826862211 161248164 127752092 588008547 464594788 223966593 612768641 344208726 166047379 900514231 275858941 212959876 559355844 350313823 553227919 666738295 25627086 350205058 831963128 222951881 468038892 140758109 666324601 701366631 195790073...
Output
4950

Answer
4950

Checker Log
ok answer is 4950

Test: #9, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 2

826862211 161248164 127752092 588008547 464594788 223966593 612768641 344208726 166047379 900514231 275858941 212959876 559355844 350313823 553227919 666738295 25627086 350205058 831963128 222951881 468038892 140758109 666324601 701366631 195790073...
Output
4950

Answer
4950

Checker Log
ok answer is 4950

Test: #10, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
74 50

77443298 530631479 42972011 465406091 260713952 423292923 623647524 555818098 759926076 85286987 982805721 4225265 723875718 663104534 455956586 183833228 119571387 562163395 341502144 943067360 118410368 781762166 564887308 948621795 137003878 803...
Output
9688739

Answer
9688739

Checker Log
ok answer is 9688739

Test: #10, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
74 50

77443298 530631479 42972011 465406091 260713952 423292923 623647524 555818098 759926076 85286987 982805721 4225265 723875718 663104534 455956586 183833228 119571387 562163395 341502144 943067360 118410368 781762166 564887308 948621795 137003878 803...
Output
9688739

Answer
9688739

Checker Log
ok answer is 9688739

Test: #11, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 500

529719761 710786792 692458955 304656259 734548399 203464943 141370066 811500065 787470957 394556684 293743516 342927735 661908866 55193322 996074889 176465858 990438855 224141668 313035644 445787022 943704504 532721353 67857945 654113275 5506705...
Output
159835829

Answer
159835829

Checker Log
ok answer is 159835829

Test: #11, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 500

529719761 710786792 692458955 304656259 734548399 203464943 141370066 811500065 787470957 394556684 293743516 342927735 661908866 55193322 996074889 176465858 990438855 224141668 313035644 445787022 943704504 532721353 67857945 654113275 5506705...
Output
159835829

Answer
159835829

Checker Log
ok answer is 159835829

Test: #12, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 20

44686827 793084314 150110490 112244423 381285160 312303297 500246839 77293258 383325734 64720077 565282664 185868151 534427376 349787264 332395080 811201800 566448833 316293660 839959749 709176151 393899592 561012645 518145117 960227363 843084773...
Output
846458288

Answer
846458288

Checker Log
ok answer is 846458288

Test: #12, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 20

44686827 793084314 150110490 112244423 381285160 312303297 500246839 77293258 383325734 64720077 565282664 185868151 534427376 349787264 332395080 811201800 566448833 316293660 839959749 709176151 393899592 561012645 518145117 960227363 843084773...
Output
846458288

Answer
846458288

Checker Log
ok answer is 846458288

Test: #13, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 700

675041533 871839794 773764849 814068361 834029032 862906558 278990662 331576364 835772707 882017508 68260956 774679313 273222083 773356669 943638646 836247084 340090701 734317094 185409389 862867283 627933178 159953278 606358761 229280636 764019...
Output
626555557

Answer
626555557

Checker Log
ok answer is 626555557

Test: #13, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 700

675041533 871839794 773764849 814068361 834029032 862906558 278990662 331576364 835772707 882017508 68260956 774679313 273222083 773356669 943638646 836247084 340090701 734317094 185409389 862867283 627933178 159953278 606358761 229280636 764019...
Output
626555557

Answer
626555557

Checker Log
ok answer is 626555557

Test: #14, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 47

624726598 393839535 708499822 275954739 513789812 382519792 861107207 278537144 401013656 445731033 905771510 220246090 790130311 241312369 292347941 689569679 887777426 664016585 430843290 164793812 663025604 325172539 705860276 256899920 674549...
Output
736901467

Answer
736901467

Checker Log
ok answer is 736901467

Test: #14, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 47

624726598 393839535 708499822 275954739 513789812 382519792 861107207 278537144 401013656 445731033 905771510 220246090 790130311 241312369 292347941 689569679 887777426 664016585 430843290 164793812 663025604 325172539 705860276 256899920 674549...
Output
736901467

Answer
736901467

Checker Log
ok answer is 736901467

Test: #15, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 1000

291503277 270821080 992679888 303991127 32040145 58467425 378099964 484025421 148341045 816193039 925311405 136463493 50656576 915053664 741360750 50676397 798402037 401546751 168007431 553094715 840910637 498209536 889665464 504580785 19551766...
Output
1

Answer
1

Checker Log
ok answer is 1

Test: #15, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 1000

291503277 270821080 992679888 303991127 32040145 58467425 378099964 484025421 148341045 816193039 925311405 136463493 50656576 915053664 741360750 50676397 798402037 401546751 168007431 553094715 840910637 498209536 889665464 504580785 19551766...
Output
1

Answer
1

Checker Log
ok answer is 1

Test: #16, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 1

496647218 737868529 337909093 754756319 417368682 262061269 484174162 904435562 327058813 451709619 107867621 494741662 629686275 921009391 687539041 372436692 486281149 469433382 757851095 329386047 75488984 444948082 318612063 284462635 4489147...
Output
10000

Answer
10000

Checker Log
ok answer is 10000

Test: #16, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 1

496647218 737868529 337909093 754756319 417368682 262061269 484174162 904435562 327058813 451709619 107867621 494741662 629686275 921009391 687539041 372436692 486281149 469433382 757851095 329386047 75488984 444948082 318612063 284462635 4489147...
Output
10000

Answer
10000

Checker Log
ok answer is 10000

Test: #17, time: 110 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
7458 585

531676192 78578119 345746072 296530099 415994523 272733438 716068723 580790576 468094712 650661519 378230832 542037898 750690318 743761227 631712347 522422895 976963250 944033490 41803173 48899715 941605886 527393751 720867871 610889881 73039297...
Output
625994608

Answer
625994608

Checker Log
ok answer is 625994608

Test: #17, time: 110 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
7458 585

531676192 78578119 345746072 296530099 415994523 272733438 716068723 580790576 468094712 650661519 378230832 542037898 750690318 743761227 631712347 522422895 976963250 944033490 41803173 48899715 941605886 527393751 720867871 610889881 73039297...
Output
625994608

Answer
625994608

Checker Log
ok answer is 625994608

Test: #18, time: 110 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 1000

916521956 860130379 36216667 958579180 628524832 959265874 552689325 354223939 402103756 164682295 364578406 886914944 598610298 641842563 13074729 551435812 70578669 128424512 316315370 505072468 826499421 165714747 231327537 291582484 732575...
Output
155349879

Answer
155349879

Checker Log
ok answer is 155349879

Test: #18, time: 110 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 1000

916521956 860130379 36216667 958579180 628524832 959265874 552689325 354223939 402103756 164682295 364578406 886914944 598610298 641842563 13074729 551435812 70578669 128424512 316315370 505072468 826499421 165714747 231327537 291582484 732575...
Output
155349879

Answer
155349879

Checker Log
ok answer is 155349879

Test: #19, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5000

471681495 586956272 783198764 482353502 660268529 193550152 158145372 873201622 593557736 398789230 562482895 401666934 397435284 532345399 666546620 723108061 380973212 33930906 385775694 151629291 12188349 632136435 207169504 78082563 672807...
Output
2413012

Answer
2413012

Checker Log
ok answer is 2413012

Test: #19, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5000

471681495 586956272 783198764 482353502 660268529 193550152 158145372 873201622 593557736 398789230 562482895 401666934 397435284 532345399 666546620 723108061 380973212 33930906 385775694 151629291 12188349 632136435 207169504 78082563 672807...
Output
2413012

Answer
2413012

Checker Log
ok answer is 2413012

Test: #20, time: 130 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
84584 5845

152530093 739507372 673778498 733067593 351783766 470974551 28787771 989676522 193267568 550093277 853776895 664922558 839413110 728863065 552273023 716604895 539506974 191108019 694541959 925429458 787003546 42628572 515599612 412763075 88490...
Output
466605776

Answer
466605776

Checker Log
ok answer is 466605776

Test: #20, time: 130 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
84584 5845

152530093 739507372 673778498 733067593 351783766 470974551 28787771 989676522 193267568 550093277 853776895 664922558 839413110 728863065 552273023 716604895 539506974 191108019 694541959 925429458 787003546 42628572 515599612 412763075 88490...
Output
466605776

Answer
466605776

Checker Log
ok answer is 466605776

Test: #21, time: 140 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 5845

803599302 254920084 613634972 69431551 18816062 319288898 544138727 33290550 984328877 131135233 685995250 451969757 88420595 112186097 749218685 824263003 754764224 984965455 665219132 545705561 621448408 976839614 291845137 481427457 502069...
Output
448954658

Answer
448954658

Checker Log
ok answer is 448954658

Test: #21, time: 140 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 5845

803599302 254920084 613634972 69431551 18816062 319288898 544138727 33290550 984328877 131135233 685995250 451969757 88420595 112186097 749218685 824263003 754764224 984965455 665219132 545705561 621448408 976839614 291845137 481427457 502069...
Output
448954658

Answer
448954658

Checker Log
ok answer is 448954658

Test: #22, time: 140 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 10000

13198223 122358989 186385479 745208948 245407983 701394017 796904220 141142724 184149360 990787036 9264224 377907585 511269648 468090335 321407066 41026877 117010925 461949691 919482258 196400539 842897034 757935605 943129364 913744782 85319...
Output
803016460

Answer
803016460

Checker Log
ok answer is 803016460

Test: #22, time: 140 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 10000

13198223 122358989 186385479 745208948 245407983 701394017 796904220 141142724 184149360 990787036 9264224 377907585 511269648 468090335 321407066 41026877 117010925 461949691 919482258 196400539 842897034 757935605 943129364 913744782 85319...
Output
803016460

Answer
803016460

Checker Log
ok answer is 803016460

Test: #23, time: 160 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 50000

745369635 434713881 497917523 944170214 2223246 833670473 422472499 500327985 161330463 687305563 580059540 453050372 947596342 98376633 493485870 445363274 989878129 354180829 608418587 269890590 947617781 832677780 386171926 631135759 5612...
Output
149033233

Answer
149033233

Checker Log
ok answer is 149033233

Test: #23, time: 160 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 50000

745369635 434713881 497917523 944170214 2223246 833670473 422472499 500327985 161330463 687305563 580059540 453050372 947596342 98376633 493485870 445363274 989878129 354180829 608418587 269890590 947617781 832677780 386171926 631135759 5612...
Output
149033233

Answer
149033233

Checker Log
ok answer is 149033233

Test: #24, time: 200 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 94584

74598276 912169856 98651881 176402500 93053050 88312769 138646180 177638546 747793903 41838929 244381228 924203215 588975162 500821485 700245620 224282905 678920634 228997481 25467163 486658893 206034460 895074036 375453095 373626942 5186507...
Output
964980403

Answer
964980403

Checker Log
ok answer is 964980403

Test: #24, time: 200 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 94584

74598276 912169856 98651881 176402500 93053050 88312769 138646180 177638546 747793903 41838929 244381228 924203215 588975162 500821485 700245620 224282905 678920634 228997481 25467163 486658893 206034460 895074036 375453095 373626942 5186507...
Output
964980403

Answer
964980403

Checker Log
ok answer is 964980403

Test: #25, time: 90 ms., memory: 4968 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 7

44447444 747774747 77777447 444447 777444747 7777444 4747774 474777447 774774 477474777 7447744 777774774 7444 74744774 4747774 477444474 47444447 474474747 74474447 44747447 4747747 447474477 474447 444447777 77777477 74474477 774774 447477777 444...
Output
334870375

Answer
334870375

Checker Log
ok answer is 334870375

Test: #25, time: 90 ms., memory: 4968 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 7

44447444 747774747 77777447 444447 777444747 7777444 4747774 474777447 774774 477474777 7447744 777774774 7444 74744774 4747774 477444474 47444447 474474747 74474447 44747447 4747747 447474477 474447 444447777 77777477 74474477 774774 447477777 444...
Output
334870375

Answer
334870375

Checker Log
ok answer is 334870375

Test: #26, time: 90 ms., memory: 4968 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 50

74774447 477774744 777744 447744744 77777 44444777 774777447 777777 44744777 74744 444444774 774744444 774474777 444774774 47774477 44744477 777774747 74777447 777777477 44444 447444477 477444 747777747 744744 474774474 747477477 774774744 7747744...
Output
212150217

Answer
212150217

Checker Log
ok answer is 212150217

Test: #26, time: 90 ms., memory: 4968 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 50

74774447 477774744 777744 447744744 77777 44444777 774777447 777777 44744777 74744 444444774 774744444 774474777 444774774 47774477 44744477 777774747 74777447 777777477 44444 447444477 477444 747777747 744744 474774474 747477477 774774744 7747744...
Output
212150217

Answer
212150217

Checker Log
ok answer is 212150217

Test: #27, time: 80 ms., memory: 4964 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
74 58

7777744 4747747 744474474 7747744 447477777 444747474 74744 74447747 77444444 74444744 747447477 447777777 747744447 44447444 7444477 777774 744774777 444777444 777747477 47747774 44474474 4747477 774444 477774744 447744447 44477474 47444 44774774 ...
Output
211649703

Answer
211649703

Checker Log
ok answer is 211649703

Test: #27, time: 80 ms., memory: 4964 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
74 58

7777744 4747747 744474474 7747744 447477777 444747474 74744 74447747 77444444 74444744 747447477 447777777 747744447 44447444 7444477 777774 744774777 444777444 777747477 47747774 44474474 4747477 774444 477774744 447744447 44477474 47444 44774774 ...
Output
211649703

Answer
211649703

Checker Log
ok answer is 211649703

Test: #28, time: 90 ms., memory: 5000 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 10

477474747 74774444 44747447 47477774 47747 474747747 77744744 474444447 77777 777474474 774777447 77747474 74477774 777777477 47774 777477744 477477477 477747777 47444477 774444744 747444774 477744447 4474 4477774 774744744 4774747 44747444 47777...
Output
390204758

Answer
390204758

Checker Log
ok answer is 390204758

Test: #28, time: 90 ms., memory: 5000 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 10

477474747 74774444 44747447 47477774 47747 474747747 77744744 474444447 77777 777474474 774777447 77747474 74477774 777777477 47774 777477744 477477477 477747777 47444477 774444744 747444774 477744447 4474 4477774 774744744 4774747 44747444 47777...
Output
390204758

Answer
390204758

Checker Log
ok answer is 390204758

Test: #29, time: 90 ms., memory: 5000 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 999

477744747 44777477 774474774 747747747 74777744 4774474 44777747 47747477 477444477 447444774 474477777 44444777 744744744 477777444 477747447 4774774 444744 44744774 47774474 4774774 477474477 74477774 7444 477774474 7444 474477477 477747774 47...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #29, time: 90 ms., memory: 5000 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 999

477744747 44777477 774474774 747747747 74777744 4774474 44777747 47747477 477444477 447444774 474477777 44444777 744744744 477777444 477747447 4774774 444744 44744774 47774474 4774774 477474477 74477774 7444 477774474 7444 474477477 477747774 47...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #30, time: 110 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5845

777447474 474474774 77744774 47474 744744744 47447747 47447444 74747474 47774747 744444747 447447447 47747777 777777477 77477444 4747444 4744774 7747477 774477 44447744 77774777 447777774 447477777 7474474 74777477 477777477 444744747 444474 4...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #30, time: 110 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5845

777447474 474474774 77744774 47474 744744744 47447747 47447444 74747474 47774747 744444747 447447447 47747777 777777477 77477444 4747444 4744774 7747477 774477 44447744 77774777 447777774 447477777 7474474 74777477 477777477 444744747 444474 4...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #31, time: 110 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
5845 98

44747474 444744777 47744447 744474477 44747777 774477444 777477777 744447774 447774477 47444744 74444474 447477444 74777474 747 7744747 444777474 47774777 777777474 447477447 447774777 774774444 474474774 774444774 7474774 477777474 47477777 4474...
Output
593789471

Answer
593789471

Checker Log
ok answer is 593789471

Test: #31, time: 110 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
5845 98

44747474 444744777 47744447 744474477 44747777 774477444 777477777 744447774 447774477 47444744 74444474 447477444 74777474 747 7744747 444777474 47774777 777777474 447477447 447774777 774774444 474474774 774444774 7474774 477777474 47477777 4474...
Output
593789471

Answer
593789471

Checker Log
ok answer is 593789471

Test: #32, time: 130 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5000

44474477 7744744 74774447 7744447 774744777 744 74747 444774 74447477 447744777 77744747 44474777 44744447 447444447 447447 447744774 444474444 47777774 4444777 774444444 444444444 4447474 744447447 7447774 744744777 477774444 77447774 7474474...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #32, time: 130 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5000

44474477 7744744 74774447 7744447 774744777 744 74747 444774 74447477 447744777 77744747 44474777 44744447 447444447 447447 447744774 444474444 47777774 4444777 774444444 444444444 4447474 744447447 7447774 744744777 477774444 77447774 7474474...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #33, time: 200 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 10

774777 47474777 774474747 444447447 774447744 447747447 774744477 474447444 477474447 74477747 744774444 477444447 744747777 7777774 74774747 477747774 744444474 47744774 474474477 747777774 77474774 7747 74477774 47744777 444744 74747447 74474...
Output
984819351

Answer
984819351

Checker Log
ok answer is 984819351

Test: #33, time: 200 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 10

774777 47474777 774474747 444447447 774447744 447747447 774744477 474447444 477474447 74477747 744774444 477444447 744747777 7777774 74774747 477747774 744444474 47744774 474474477 747777774 77474774 7747 74477774 47744777 444744 74747447 74474...
Output
984819351

Answer
984819351

Checker Log
ok answer is 984819351

Test: #34, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 69

447444774 77774 774444444 447777474 474474447 447777477 777744 477777777 477474747 777774744 774444744 777477744 774447 7747 744747474 477477777 444747774 444474747 74447777 747 777477477 744447777 44444777 44444744 47774777 774474744 474474747...
Output
277790058

Answer
277790058

Checker Log
ok answer is 277790058

Test: #34, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 69

447444774 77774 774444444 447777474 474474447 447777477 777744 477777777 477474747 777774744 774444744 777477744 774447 7747 744747474 477477777 444747774 444474747 74447777 747 777477477 744447777 44444777 44444744 47774777 774474744 474474747...
Output
277790058

Answer
277790058

Checker Log
ok answer is 277790058

Test: #35, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 50000

77744477 777744477 444747774 747744444 774444777 44444777 447447444 744777774 44777477 477474744 747447774 444474477 477444 4774444 74477474 444777774 4474744 4747747 4444477 444774777 447447747 777477444 74747474 77444777 47744744 444777447...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #35, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 50000

77744477 777744477 444747774 747744444 774444777 44444777 447447444 744777774 44777477 477474744 747447774 444474477 477444 4774444 74477474 444777774 4474744 4747747 4444477 444774777 447447747 777477444 74747474 77444777 47744744 444777447...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #36, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 100000

744747444 744477474 747744447 47474744 444444474 74744444 7744744 74777 44444477 474447744 777477744 47774474 477474 777744777 747444474 4477747 477444447 74774474 747777 474777 44777 47774 44744444 7477744 444444477 74747774 747477447 4777...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #36, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 100000

744747444 744477474 747744447 47474744 444444474 74744444 7744744 74777 44444477 474447744 777477744 47774474 477474 777744777 747444474 4477747 477444447 74774474 747777 474777 44777 47774 44744444 7477744 444444477 74747774 747477447 4777...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #37, time: 220 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 1

477447477 447744 44447477 744447744 774447777 774744447 744444474 774747447 777474774 77447474 744474444 444774744 74444 747447747 747774 447447447 447447474 447477744 447447447 7477 7474744 44777777 7744774 447474474 477477777 747747747 4777447...
Output
100000

Answer
100000

Checker Log
ok answer is 100000

Test: #37, time: 220 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 1

477447477 447744 44447477 744447744 774447777 774744447 744444474 774747447 777474774 77447474 744474444 444774744 74444 747447747 747774 447447447 447447474 447477744 447447447 7477 7474744 44777777 7744774 447474474 477477777 747747747 4777447...
Output
100000

Answer
100000

Checker Log
ok answer is 100000

Test: #38, time: 90 ms., memory: 4964 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 36

383840915 77744747 309758403 7447444 477774447 460135679 747747744 452244803 44477774 108627669 169132452 912493899 4774744 744477 474477744 645796042 7477774 744744744 747 612567580 818500508 44474747 44777477 744447747 491390115 774474744 474777...
Output
312263098

Answer
312263098

Checker Log
ok answer is 312263098

Test: #38, time: 90 ms., memory: 4964 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100 36

383840915 77744747 309758403 7447444 477774447 460135679 747747744 452244803 44477774 108627669 169132452 912493899 4774744 744477 474477744 645796042 7477774 744744744 747 612567580 818500508 44474747 44777477 744447747 491390115 774474744 474777...
Output
312263098

Answer
312263098

Checker Log
ok answer is 312263098

Test: #39, time: 90 ms., memory: 4984 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 584

261492520 818267504 474744477 709978214 447777744 44477447 435278241 523761347 44777444 744744747 477444447 385572088 740453952 551180296 634495387 228258015 628117734 744444744 747477747 896778095 439250368 747777447 746241784 7474474 958304240...
Output
203769708

Answer
203769708

Checker Log
ok answer is 203769708

Test: #39, time: 90 ms., memory: 4984 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 584

261492520 818267504 474744477 709978214 447777744 44477447 435278241 523761347 44777444 744744747 477444447 385572088 740453952 551180296 634495387 228258015 628117734 744444744 747477747 896778095 439250368 747777447 746241784 7474474 958304240...
Output
203769708

Answer
203769708

Checker Log
ok answer is 203769708

Test: #40, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
99999 584

444474474 74447444 774447474 774474444 733949779 972396513 653412573 77777744 7747447 777444747 150752846 800359795 647212796 74444774 894880236 75297986 474474777 777447474 520294893 4747744 47744447 59301543 605145383 332116730 173958717 7744...
Output
768302301

Answer
768302301

Checker Log
ok answer is 768302301

Test: #40, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
99999 584

444474474 74447444 774447474 774474444 733949779 972396513 653412573 77777744 7747447 777444747 150752846 800359795 647212796 74444774 894880236 75297986 474474777 777447474 520294893 4747744 47744447 59301543 605145383 332116730 173958717 7744...
Output
768302301

Answer
768302301

Checker Log
ok answer is 768302301

Test: #41, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 10000

744477744 77747444 447744444 141142724 990787036 377907585 468090335 41026877 74747477 196400539 757935605 913744782 744747747 474774774 411215630 74477 477744774 444744444 68843184 444774747 74747444 477474444 477444477 7474447 777777474 77...
Output
611040800

Answer
611040800

Checker Log
ok answer is 611040800

Test: #41, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 10000

744477744 77747444 447744444 141142724 990787036 377907585 468090335 41026877 74747477 196400539 757935605 913744782 744747747 474774774 411215630 74477 477744774 444744444 68843184 444774747 74747444 477474444 477444477 7474447 777777474 77...
Output
611040800

Answer
611040800

Checker Log
ok answer is 611040800

Test: #42, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 4

774444744 747474444 287671162 53686218 44477477 747744474 47474477 74474747 264958056 777774477 44477774 744744747 4447477 154092553 933534591 477477747 36978187 864508738 865805105 744777444 474076943 295898148 282668528 777774447 127819655 777...
Output
674552894

Answer
674552894

Checker Log
ok answer is 674552894

Test: #42, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 4

774444744 747474444 287671162 53686218 44477477 747744474 47474477 74474747 264958056 777774477 44477774 744744747 4447477 154092553 933534591 477477747 36978187 864508738 865805105 744777444 474076943 295898148 282668528 777774447 127819655 777...
Output
674552894

Answer
674552894

Checker Log
ok answer is 674552894

Test: #43, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 1

510370856 744447744 774744447 774747447 77447474 444774744 614187304 939117966 741610015 477693985 285312674 447474474 959557237 777774 447444 7447747 674800447 744777 685671576 477747747 774477774 775204530 444444777 39464045 444447447 43059241...
Output
100000

Answer
100000

Checker Log
ok answer is 100000

Test: #43, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 1

510370856 744447744 774744447 774747447 77447474 444774744 614187304 939117966 741610015 477693985 285312674 447474474 959557237 777774 447444 7447747 674800447 744777 685671576 477747747 774477774 775204530 444444777 39464045 444447447 43059241...
Output
100000

Answer
100000

Checker Log
ok answer is 100000

Test: #44, time: 90 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5000

7744744 482353502 744 873201622 398789230 44474777 532345399 723108061 33930906 151629291 4447474 78082563 736769083 747447474 70526800 447477474 77747744 447744474 744474474 774744444 529834376 77444444 4474474 662073071 725666654 688505404 7...
Output
872029798

Answer
872029798

Checker Log
ok answer is 872029798

Test: #44, time: 90 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
10000 5000

7744744 482353502 744 873201622 398789230 44474777 532345399 723108061 33930906 151629291 4447474 78082563 736769083 747447474 70526800 447477474 77747744 447744474 744474474 774744444 529834376 77444444 4474474 662073071 725666654 688505404 7...
Output
872029798

Answer
872029798

Checker Log
ok answer is 872029798

Test: #45, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
88888 9945

477744747 44474774 447777 534497000 777744444 584794900 270077960 444777447 17240206 609283479 77477444 7474744 744447 330368555 7444744 774747444 447747 433825207 447477777 900439354 47477747 744747774 128927840 47477777 777774747 74 47774777...
Output
252151622

Answer
252151622

Checker Log
ok answer is 252151622

Test: #45, time: 170 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
88888 9945

477744747 44474774 447777 534497000 777744444 584794900 270077960 444777447 17240206 609283479 77477444 7474744 744447 330368555 7444744 774747444 447747 433825207 447477777 900439354 47477747 744747774 128927840 47477777 777774747 74 47774777...
Output
252151622

Answer
252151622

Checker Log
ok answer is 252151622

Test: #46, time: 220 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 50000

777744477 747744444 833670473 744777774 477474744 453050372 98376633 445363274 4747747 444774777 777477444 631135759 444777447 604996701 835396619 7744747 4777444 747444 777477747 777747444 477474444 323180425 609722669 47474444 968830146 47...
Output
763264716

Answer
763264716

Checker Log
ok answer is 763264716

Test: #46, time: 220 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 50000

777744477 747744444 833670473 744777774 477474744 453050372 98376633 445363274 4747747 444774777 777477444 631135759 444777447 604996701 835396619 7744747 4777444 747444 777477747 777747444 477474444 323180425 609722669 47474444 968830146 47...
Output
763264716

Answer
763264716

Checker Log
ok answer is 763264716

Test: #47, time: 110 ms., memory: 5020 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
5000 5000

44474 506760126 444747744 474474447 710276155 99267375 829745100 74474747 101093617 811297418 4744744 477474 464976342 962245504 716112016 47447 12920657 21832286 842131518 774477444 733950056 944459795 258692360 623271757 403508930 444777774 4...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #47, time: 110 ms., memory: 5020 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
5000 5000

44474 506760126 444747744 474474447 710276155 99267375 829745100 74474747 101093617 811297418 4744744 477474 464976342 962245504 716112016 47447 12920657 21832286 842131518 774477444 733950056 944459795 258692360 623271757 403508930 444777774 4...
Output
0

Answer
0

Checker Log
ok answer is 0

Test: #48, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
5 2

47 47 47 47 47

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #48, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
5 2

47 47 47 47 47

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #49, time: 160 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 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...
Output
149033233

Answer
149033233

Checker Log
ok answer is 149033233

Test: #49, time: 160 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 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...
Output
149033233

Answer
149033233

Checker Log
ok answer is 149033233

Test: #50, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
13 5

44 44 44 44 44 44 44 44 77 55 66 99 55

Output
41

Answer
41

Checker Log
ok answer is 41

Test: #50, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
13 5

44 44 44 44 44 44 44 44 77 55 66 99 55

Output
41

Answer
41

Checker Log
ok answer is 41

Test: #51, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
3 2

1 47 47

Output
2

Answer
2

Checker Log
ok answer is 2

Test: #51, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
3 2

1 47 47

Output
2

Answer
2

Checker Log
ok answer is 2

Test: #52, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 200

44447447 444744444 447744477 777477474 77444444 477444477 447774744 74777447 477444444 777477777 7447474 744474447 774447747 477747744 747777747 477774744 777477477 747477747 74777444 474744444 747744444 47447447 77474444 447447474 4744744 444...
Output
911573240

Answer
911573240

Checker Log
ok answer is 911573240

Test: #52, time: 230 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 200

44447447 444744444 447744477 777477474 77444444 477444477 447774744 74777447 477444444 777477777 7447474 744474447 774447747 477747744 747777747 477774744 777477477 747477747 74777444 474744444 747744444 47447447 77474444 447447474 4744744 444...
Output
911573240

Answer
911573240

Checker Log
ok answer is 911573240

Test: #53, time: 160 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 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...
Output
149033233

Answer
149033233

Checker Log
ok answer is 149033233

Test: #53, time: 160 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
100000 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...
Output
149033233

Answer
149033233

Checker Log
ok answer is 149033233

Test: #54, time: 90 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2044 1000

4 44 444 4444 44444 444444 4444444 44444444 444444444 444444447 44444447 444444474 444444477 4444447 44444474 444444744 444444747 44444477 444444774 444444777 444447 4444474 44444744 444447444 444447447 44444747 444447474 444447477 4444477 4444...
Output
58844659

Answer
58844659

Checker Log
ok answer is 58844659

Test: #54, time: 90 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2044 1000

4 44 444 4444 44444 444444 4444444 44444444 444444444 444444447 44444447 444444474 444444477 4444447 44444474 444444744 444444747 44444477 444444774 444444777 444447 4444474 44444744 444447444 444447447 44444747 444447474 444447477 4444477 4444...
Output
58844659

Answer
58844659

Checker Log
ok answer is 58844659

Test: #55, time: 110 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2 2

47 47

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #55, time: 110 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2 2

47 47

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #56, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2 2

44 44

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #56, time: 90 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
2 2

44 44

Output
0

Answer
0

Checker Log
ok answer is 0

Test: #57, time: 90 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1731 1000

7 4 4 77 47 47 74 44 44 777 477 477 747 447 447 774 474 474 744 444 444 7777 4777 4777 7477 4477 4477 7747 4747 4747 7447 4447 4447 7774 4774 4774 7474 4474 4474 7744 4744 4744 7444 4444 4444 77777 47777 47777 74777 44777 44777 77477 47477 4747...
Output
7081626

Answer
7081626

Checker Log
ok answer is 7081626

Test: #57, time: 90 ms., memory: 5024 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1731 1000

7 4 4 77 47 47 74 44 44 777 477 477 747 447 447 774 474 474 744 444 444 7777 4777 4777 7477 4477 4477 7747 4747 4747 7447 4447 4447 7774 4774 4774 7474 4474 4474 7744 4744 4744 7444 4444 4444 77777 47777 47777 74777 44777 44777 77477 47477 4747...
Output
7081626

Answer
7081626

Checker Log
ok answer is 7081626

Test: #58, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 100

7 26500 47 29358 24464 474 444444 7 4 447 47 153 12382 777777 19895 777777 47 447 477 444777 777444 30333 47 777444 747 747 32757 477 777444 747 3035 1842 30106 8942 22648 23805 6729 15350 31101 744 774 19954 11840 7376 47 32439 11323 744 2082 4...
Output
96898382

Answer
96898382

Checker Log
ok answer is 96898382

Test: #58, time: 80 ms., memory: 4960 KB, exit code: 0, checker exit code: 0, verdict: OK
Input
1000 100

7 26500 47 29358 24464 474 444444 7 4 447 47 153 12382 777777 19895 777777 47 447 477 444777 777444 30333 47 777444 747 747 32757 477 777444 747 3035 1842 30106 8942 22648 23805 6729 15350 31101 744 774 19954 11840 7376 47 32439 11323 744 2082 4...
Output
96898382

Answer
96898382

Checker Log
ok answer is 96898382


分享到:
评论

相关推荐

    Codeforces Round #723 (Div. 2).md

    Codeforces Round #723 (Div. 2).md

    Codeforces Round #630 (Div. 2) D. Walk on Matrix(构造)

    上面代码跑出来的dp[n][m]是0,然后从(1,1)(1,2)(2,2)(2,3)这样的相与值是k (看懂ans+k是啥应该就懂了) 代码: int main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int ans=(1&...

    Codeforces Round #627 (Div. 3) C. Frog Jumps(思维)

    传送门 题意: 开始位置在0,问能否跳到n+1位置 每步只能跳d 在1——n每个位置有方向,L,R,求d的最小值 思路: 只用找相邻两个R之间的最大值即可 代码: #include #include ...typedef long long l

    Codeforces Round #627 (Div. 3) B. Yet Another Palindrome Problem

    就是把所有相等的数放到一个vector里,如果他出现大于2次,看最远的间距是否大于2即可,找到一个就可以 代码: #include #include #include #include #include #include #include #include #include #include #...

    Codeforces Round #629 (Div. 3) B. K-th Beautiful String

    长度为n的字符串包含n−2n−2n−2个aaa和222个bbb,求按照字典序排列输出第kkk个字符串 解题思路 第一个bbb在倒数第二位有1个字符串,在倒数第三位有2个字符串…在倒数第nnn位时有n−1n-1n−1个字符串 可以根据第一...

    Codeforces Round #479 (Div. 3) E. Cyclic Components

    E. Cyclic Components 题目链接-E. Cyclic Components 题目大意 给你nnn个点和mmm条边,求所构成图中单圈环的个数 解题思路 并查集并查集并查集 很明显单圈环每个点的度都为222,所以我们可以用数组cnt[]记录每...

    Codeforces Round #629 (Div. 3) E.Tree Queries (DFS)

    Codeforces Round #629 (Div. 3) E.Tree Queries (DFS) 思路:若ai 在路径上 ,则ai的父结点一定在路径上,若ai是路径上某个结点的子结点,则ai的父结点一定在路径上,综上只需考虑ai的父节点就行了。对每个ai判断...

    Codeforces Round #628 (Div. 2)

    给两两节点放一个数字(0~n-2 唯一) 给你一棵树,求所有任意两节点相连的路以外的路上的数字的最小值最小 思路 构造 若一个点连了三条边及以上,则这个点的边从最小值开始赋值。其他边从最大点开始赋值。 证明:一...

    Codeforces Round #620 (Div. 2) Longest Palindrome

    B. Longest Palindrome time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Returning back to problem solving, Gildong is now studying about ...

    Codeforces Round #628 (Div. 2) A. EhAb AnD gCd

    输入一个正整数x,找出这样的2个正整数a和b,使得gcd(a,b)+lcm(a,b)=x 解题思路 找最特殊的情况a=1,b=x-1即可 这样a,b两个数最大公因数为1,最小公倍数x-1,满足题意√ 附上代码 #include #define int long long #...

    Codeforces Round #635 (Div. 2)D. Xenia and Colorful Gems

    传说门 刚好今晚是中国场! 其实这道题比较水,但当时思路错,一心想着化简公式,浪费了好多时间a....#pragma GCC optimize(2) #include #define ll long long #define endl '\n' using namespace std; const int manx=

    Codeforces Round #628 (Div. 2) A~~D

    A #include using namespace std; typedef long long ll; int main(){ int t; cin&gt;&gt;t; while(t--){ ll x; cin&gt;&gt;x; cout&lt;&lt;1&gt;&gt;t; while(t--){ st.clear(); ll n; cin &gt;&gt;n;... ll re

    Codeforces Round #628 (Div. 2)【A B C D】

    传送门 A. EhAb AnD gCd 直接输出1,n-1即可 #include #include #include #include #include #include #include #include #include #include #define pb push_back #define lb lower_bound ...con

    Codeforces Round #633 (Div. 2) A. Filling Diamonds(找规律)

    传送门 题意: 找规律,题意就是有多少种方式填充该图形 画两个就发现,输出n即可 代码: #include #include #include #include #include #include #include #include ...#define SZ(x) ((int)(x)

    【Codeforces Round#620 (Div. 2)】B. Longest Palindrome 题解

    题目链接:B. Longest Palindrome 题目 Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse....

    Codeforces Round #627 (Div. 3) A. Yet Another Tetris Problem

    给一个长度为n的数组,两种操作,一个是把任意一个ai变成ai+2a_i变成a_i+2ai​变成ai​+2,另一个是如果所有数都大于0,可以把所有数减1,问通过这些操作能否把所有数变为0 思路: 如果任意两个数之差为奇数,那么就...

    Codeforces Round #629 (Div. 3) E – Tree Queries dfs序判祖先关系

    惭愧,前几天刚学的dfs序判祖先关系都忘了用。。 这题我们先把所有点都变成父亲节点(根节点不变),这样只需要判所有节点是否在一条链上。 由于判断x是y的祖先:需要满足:st[x]&lt;...const int M = 2e5+

    Codeforces Round #633 (Div. 2) B. Sorted Adjacent Differences(排序,思维)

    -2,4,5,5,6,8 要输出的序列应该是每次从前面选一个,然后从后面选一个 -2,8,4,6,5,5 然后把该序列倒着输出即可 代码: #include #include #include #include #include #include #include #include #...

Global site tag (gtag.js) - Google Analytics