QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650332#1341. Route Calculator ReturnsAfterlife#AC ✓92ms70008kbC++201.3kb2024-10-18 14:40:492024-10-18 14:40:49

Judging History

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

  • [2024-10-18 14:40:49]
  • 评测
  • 测评结果:AC
  • 用时:92ms
  • 内存:70008kb
  • [2024-10-18 14:40:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n , m , mod;
string s[2005];
int c[2005][2005];
int f[2005][2005];
int g[2005][2005];
int h[2005][2005];
int main() {
    cin >> n >> m >> mod ;
    for(int i = 1;i <= n;i++) {
        cin >> s[i]  ; s[i] = "$" + s[i] ;
    }
    c[1][1] = 1 ;f[1][1] = 0 ; g[1][1] = 1 ; h[1][1] = s[1][1] - '0';
    for(int i = 1;i <= n;i++) {
        for(int j = 1;j <= m;j++) {
            if(i == 1 && j == 1) continue ;
            c[i][j] = (c[i - 1][j] + c[i][j - 1]) % mod;
            f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;
            g[i][j] = (g[i - 1][j] + g[i][j - 1]) % mod;
            h[i][j] = (h[i - 1][j] + h[i][j - 1]) % mod;
            if('0' <= s[i][j] && s[i][j] <= '9') {
                int x = s[i][j] - '0' ;
                h[i][j] = (10LL * h[i][j] + 1LL * g[i][j] * x) %mod;
            }
            else if(s[i][j] == '*') {
                g[i][j] = h[i][j] ;
                h[i][j] = 0;
            }
            else {
                f[i][j] = (f[i][j] + h[i][j]) % mod;
                h[i][j] = 0; g[i][j] = c[i][j];
            }
            // printf("%d %d : %d %d %d %d\n",i,j,f[i][j],g[i][j],h[i][j],c[i][j]) ;
        }
    }
    int ans = (f[n][m] + h[n][m]) % mod;
    cout << ans << '\n' ; return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 3 1000
3*1
+27

output:

162

result:

ok answer is '162'

Test #2:

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

input:

4 4 3000000
24+7
*23*
9+48
*123

output:

2159570

result:

ok answer is '2159570'

Test #3:

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

input:

9 10 265734986
4589683*94
358827*237
*4+1895397
9664395819
7849157276
6*857+7595
4282797+59
8+655686+5
3396877+28

output:

218277171

result:

ok answer is '218277171'

Test #4:

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

input:

8 9 861597974
269*56956
+419+4199
514996859
6969*2284
933614861
889581932
18*94+946
968226933

output:

508269950

result:

ok answer is '508269950'

Test #5:

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

input:

10 10 469412705
747334*763
7847972332
3+79199922
671464426+
*624278449
3975823453
1553338*4*
685175*395
8577423*7+
664228+294

output:

59052483

result:

ok answer is '59052483'

Test #6:

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

input:

9 9 47565601
896847257
63632*836
*3+951335
4618*8293
*12425847
36749321*
89*42+8+1
*573+9442
185248525

output:

26636473

result:

ok answer is '26636473'

Test #7:

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

input:

9 8 268768043
191+963+
*5555528
21253746
2+764561
78235138
76+5+625
88364212
24*47791
2+336928

output:

1197157

result:

ok answer is '1197157'

Test #8:

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

input:

7 10 172859532
1123168269
9333581349
992+1+61*2
+644853393
8928475157
98+9893+48
7174855267

output:

77694006

result:

ok answer is '77694006'

Test #9:

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

input:

9 7 313510780
74*468+
+887726
4+42423
+5+75+5
872+247
7999918
3127*7*
8*52539
6293688

output:

139499403

result:

ok answer is '139499403'

Test #10:

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

input:

7 10 815117864
743*211*19
7698+41118
725+931455
3676*786+6
225*246223
+73717+775
1*46958447

output:

743567547

result:

ok answer is '743567547'

Test #11:

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

input:

8 7 64579902
84471+3
5147684
745337*
1*5+424
*329*64
625+5+1
9*13362
7323978

output:

3544494

result:

ok answer is '3544494'

Test #12:

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

input:

8 7 356475057
6258132
*517925
432+295
27*9*6*
5184565
658+149
+4632+8
4644849

output:

65897085

result:

ok answer is '65897085'

Test #13:

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

input:

1768 1666 35957367
69763*64232312429*24983+162855+561415686*4267+9359693*45835*6*43437492739*52544634697435+647797215322*668*3*196377215+4*1+198182+228+17745962631456*1625*7836335*5229*1662*83+8743+61*77+69145+1*91228*88213751213*271934657+9222322776377+7+853993*1223*9+655654*285+44*98*9213*57639662...

output:

5692609

result:

ok answer is '5692609'

Test #14:

score: 0
Accepted
time: 92ms
memory: 69204kb

input:

1953 1626 685529255
93*974*2*3*412+43854122844+61+968592+337+958765827451799*23958*669995+4+21536+86+1*997*5665723*443774534993628951298428373761968*42572+2527861*3481+53+195+1264*128+7646557+3219918198+176+6*4598+22*5*6+9589471511+211*355717536*7*3955*73*3+815199326795*76789+5721987169624+3194+1988...

output:

343948051

result:

ok answer is '343948051'

Test #15:

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

input:

1692 1863 624049364
68*326952+17+594353+2678957+526*71726166989+39+15375587755688112993135812397779997*7636+33+16396443+949+2*37+19+9*64+4867881467*77*86+3*5995816+1*77*656372396*3*687373*97858+346+31+8+662*471589642195459692972*61+2*8*56688+4*43138348692*1752115238815*15774+295*522948237994286*2*3+...

output:

623497331

result:

ok answer is '623497331'

Test #16:

score: 0
Accepted
time: 77ms
memory: 69900kb

input:

1915 1908 443456776
78142318231181857+3*8*6115712*491*5*9*7*4758*6+549274*5+3*2199+6*48*41+7*1341759*6659*68+772289176114+33+32149213276378193437328424*687*48715*3957*5*3*7*3823434*9772*833983+9388*9454*6896698+96788634+9*11982*48*36*4*181599*5*598925584*43388*4897+64932851*918182*3119+1+4827893*823...

output:

218688203

result:

ok answer is '218688203'

Test #17:

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

input:

1682 1740 166877186
699733+15427966*9+3732885*993*748+8575*729338+64543588772842*75836+1*1*595+9*515317856+8328744+9833*94421+727*2222+9*1733+6*38753924+54292*7+322*5814928548+7+4+9*72*383*18692667884434*749468529945568667531*522*19979829+8*3668586*6419+1*89*2*99*95884+4159+1773952517+7354353131+5+7...

output:

157267598

result:

ok answer is '157267598'

Test #18:

score: 0
Accepted
time: 86ms
memory: 69932kb

input:

1987 1865 743538955
84685+83+7*865997*4513928+6+7259513777*24551821+1535713*5*22*32*1*381+1+4*58964923818+82+5274551569*144*5*2934+6826283*76+98811*875+2875268+216898+8472446152642751916378+679579+861187671132879+374*6243334+9699496722852*79*152176128577*351*75549*82*65*555+18153246+63167955*862*388...

output:

636142136

result:

ok answer is '636142136'

Test #19:

score: 0
Accepted
time: 69ms
memory: 69288kb

input:

1738 1974 884379365
9563935693572868821972762238*337+3+6+5*11749+497*5864+7*723834288914343392+6741*1*769+6+931393*9661189855+96+638695522714317*59538995894+7+553*448+4*868399525593*22499146429679*19+55725476*88231*21161+9+74353171*217*8+1+7+854869322+6139+3866+5454513833684*192146419641474813449845...

output:

548220748

result:

ok answer is '548220748'

Test #20:

score: 0
Accepted
time: 87ms
memory: 69144kb

input:

1892 1886 938059920
7+523*84646+228455*12966145*47+1474896372633*586*8897741+45165*78337817522133867+45+239*978*1968974+79998191*98+8127+5+7*444+387534+92943986*532*5239618936315*25895*296784*92892764112929265*625563126814473*878*4263*9733*1554*5+223+78+33739*58+6646819+36*67296+5274*5*88598+5*2273*...

output:

613954784

result:

ok answer is '613954784'

Test #21:

score: 0
Accepted
time: 68ms
memory: 61768kb

input:

1635 1758 10309754
6977634*59813419772466*2469638789155427899852+22528129+67*37+65*3783*6967+118*568418*92*5248+1+257+8*9426*7*948*86755+14+11+8+3696+421539548+729*53888442556+688583*772+778536699*66245516*39155*439925179461841+266+5+64*73958899917*182+286259852+131+84494725*1*8334524+5434+16723431*...

output:

5556046

result:

ok answer is '5556046'

Test #22:

score: 0
Accepted
time: 73ms
memory: 69036kb

input:

1782 1916 144548689
594*8*644381+3+82+7+2*636+1341539733389+73538+786+29551522195+9*1759*2*986767+381144286+864424117*78*85693*236391*6+4625+656*66+761567581748*68546422562482935541871+1+44799*2*65977333278*7778+84+933+31*73219222*794432961+162663*55+7125265149*323198259*46689+336944+111133999768457...

output:

94019608

result:

ok answer is '94019608'

Test #23:

score: 0
Accepted
time: 69ms
memory: 68876kb

input:

1807 1825 246330620
7+5+3+6+4+5+4+1*5+4+8*2*8+3*7+8+4+8+1*4*9+9*2+8+9*5*6*2+4+1+9*9*4+6+6+1*7*3*9+4*2+9+5+1+7*9+5*1*9+9*5+4+3*9*5+1*9*2*3*6*4*7*6*5*2+1*6+3*3+1*8+7+2+6+2+9+4+8+9*5+8+6*3+8+7*6+5+4*5+4+7*8+3*4*7*6+4+8*8*5*2+7*6*4+7*1*1*9*1+1*9+5*1+4*3*8*7*1*3*7+7+9*9+3+7*1+9*5+5*5*5+7*8+8*2+2+8+5+4+6*...

output:

231967228

result:

ok answer is '231967228'

Test #24:

score: 0
Accepted
time: 68ms
memory: 64524kb

input:

1649 1965 419182514
2+7+8*6+3+6+3*8+7+9*6*1*4+2*7+8+6+2*2*5*2*3+6*9*9+9+7+4+6*7+5+3+4+8*2*8+8*2+9*5+7+9+8*1+3*4+2*3+1+2+6*5+9*6+9*3+4*8+7*5*7*2*9+6+8+7+7+8+2+2*3+7*3+7+7+2*1+9+1+6+5+8+2*2*1*6*5*6*2*9*9+4*8+6+5+2+8+8*4*6+4+6+1*7+5*9+6*2*2*6+2+1+1+2+3*9*3+8+9*6+6*8*2*1*6*8+8*4+4*4+1*5+6*5+7*9*7*1*4+3*...

output:

174051872

result:

ok answer is '174051872'

Test #25:

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

input:

1641 1663 244466450
6*8*3*4*2+7*2*8*5+8*4*3+2*5+9*6*9*4+2+5+5+1+2+2*5*3+2*9+6*7+6+9*3*7+7+8*7+5*6+1*1+4+6+2+7+6+3+6*1*9*4*3*2*2+7*3*4*7+6*3*8*5+4+9*8*9*4*2*5*9+5+4+5+9*4+4+4+4+2*4*2*2+6+8+5+3*9+9+6+5+7+5+5*8*6+8*3+8*4*4+4*3+3+8*9+2*5*8+4*2*7+5*8+9+9*1*5+5+2+2+9+5+8*9+7+2+2*2*6*2*8+6*6+9+6*4+5+2*4+3+...

output:

116158962

result:

ok answer is '116158962'

Test #26:

score: 0
Accepted
time: 59ms
memory: 62232kb

input:

1611 1643 892613247
4+1*8*7+8*1+2+8*3*6+4+8*3+7+5*6+7*5+3+9*2+9+6+9*5*5*3*5+9+5+1+6*1+7*2*9*1+6+5*5*2*4*1*5*9*9*8*3*8*2+7*3+4*4*4+1+6+1+1*4*4*6*6*3+7*1+6*8*5*4*7+5+6+3*4*9*6*9+4*2*7*7*7+1+8+4+8*8+6*1+1*6*1*5*6*1+8*7*7+3*5+5+8*1+3*8+4*8+2+5*8*4+1*3*1*1*4+4*1+9+4*4+3*5+5+8*6+6+8*1+7+2+8*8*1*7*2*3*2+4+...

output:

233251056

result:

ok answer is '233251056'

Test #27:

score: 0
Accepted
time: 77ms
memory: 69948kb

input:

1997 1715 407049990
6+9*6+8*4*6*4+2+2+5+8+3+3*8+6+2+5*3*5+2+3*7*7+7*6*7*8+6*4*3*6+2+2*3*5+7*3+2*3+6+2*8+5+6+5*2*3*4*4+3+4*4*4*2+3+5+8*4+3+7*6*6+3*7+1*1+3+2*1*2*1+6+6*7*7+5*5*5*4*9+9*4*2*6*8+4+9*5*3+6+8+5+5*5+4+1*5+4+9*4+5+3*5+4+4+5*1+8*8*4+8*1+8+3+6+7*6+5*9*9*8*8*2*5+9+7*6*5+4+1*6*1+9+7+1+3+4+6+5+3+...

output:

350591438

result:

ok answer is '350591438'

Test #28:

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

input:

1709 1845 508935287
6+9*9*1+6*4+3+9+3+5*3*3*6+2*3*1+2*3+5*2+8*1+3+9*6+2+3*9*2*9+8*1+4+5*7+6*9+9+8+8+7+7*4+5*1+8+5+6+3+9+8+3*5+8+7*5*6+9*2*3+4*6+3+8+1+6+1+7*7+7+6*2+1+2*2+8+5+5*1+4+6+5*3+9+7*7+3*9+3*7+7*9+5+5+4+8*1*3*6+5+6*7*7+7+2*2*3+2*7*8+4*6+7+1+7+9+7+2*6*7+3+9*5+4*5*6+2+4*3+3*9+7+3+7*5*8*4+4*5+2+...

output:

199349292

result:

ok answer is '199349292'

Test #29:

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

input:

1869 1933 817868284
8*9+2+7+1+2+9+3*3*9+4*3*6*5+4*9*5+4+3*8+8*9+6+8+7+6*1+5*6*4*8*3+7+8*9+9*5+8*1*1+9+9+6+9+8*3*2+6+5*5+2*8*8+8+5+9*3*2+8+6+3+7*8*5*3+9+3*4+1*1+8+5+9+2*4+3*8*6+7+8*5+7*2*4*6+1*8*7+3*9*1*4*5+3+1*8*7*3*8*5*5*7*8*1+2*4*2+6*1*2*7*1*9*8+5*2+5*3+1+2+3+6*6*4*9+5*8+3+3*4+6+7+7*2*8*5+2+5+1*2*...

output:

161511807

result:

ok answer is '161511807'

Test #30:

score: 0
Accepted
time: 74ms
memory: 68536kb

input:

1787 1811 571242049
7+5*1+3*5*3*5*2+2+8*9*7*9+7+5+3*5+5*8+9+4*7+1*4*3+3+1*3+2+2*9*2+1*9*4+6*9*8+1*4*9+8*7*5*6+2+6+4*5*8+4+5*8+9+5+9*4+6+7*9*4+8+9*8+7*5+2*3+7+6+4*7+2+9+2+6+9*8*5+5+2+7+6*1+3*5*2*9*7+4+8+3+6*6*8+8*3*5*7+4+1+3*6*8*9*5+2*3+5+2+3+7*7+1*7+9*2+6*1*6+6+2+4*7*2*9*9+1*6+2+7*3+1*3+6*3+1*9+1*2+...

output:

514796684

result:

ok answer is '514796684'

Test #31:

score: 0
Accepted
time: 56ms
memory: 67816kb

input:

1779 1771 964583986
8*2*8+3+8+5+7*3+6*6*1*4*6+3+5*9*8*8*3*1*8*4+7+2*4+9+1+7*3+1*3*7*3*1*9+2+2*9*8*4*1+6*5*5*3+1*3*3+6*4*7*8*9*9*9*2+2+1+2*8+4*3+7*8+6*8+8*4*8+8*7+5+7*4*3+7*2*6+5+1*6*1+7*8+3+2+6+2+3*6*7+1*2*5+8*1*8*8+3*3*5+5+8*7*3+5+4*3+7*5*3+6+2+4*3*5*6+7*3*9*7*4+9+5*4+1*8*5+4*5*3+9+7*2+7*5*1*8+9*6+...

output:

677902851

result:

ok answer is '677902851'

Test #32:

score: 0
Accepted
time: 60ms
memory: 69468kb

input:

1867 1675 44981091
9+7+6+9+4*7+7*7+4+2+5*1+7+7+1+7+6+9*8*9+7*2*7+8+8+3*4+4*8*5*1+3+4+3*5+2*7*9+6+2+8+5+1+8*2*7+5+1+3*1+3*4*8*2+8+3*8*8+1+2*9*4+9+9*2+9+6*8+8*5*4+5+6*9*8+2+5*4+7*1+7+2*8*8*1*6+6+6*4+4+2+5+9*6*1*2+8*6+3+4*4+1*7+3+5*5*2*5*7+3*4*7+6*6*4*4+8*3+7+8+5*2+3+5+3+2+7*1+9+2+3+2+1+1*7+4+4+4*1*1+8...

output:

36531507

result:

ok answer is '36531507'

Test #33:

score: 0
Accepted
time: 73ms
memory: 65320kb

input:

1682 1922 662488842
5547747763378147712652883616643661236586921831688317139534542121741723668836756422679689964992252462149178155134177368595765483274287413566538355213678949745756343146786927842186163662267333162428623726932975291312673435228976175215825827693345512363286741172142785715145822218362...

output:

454102800

result:

ok answer is '454102800'

Test #34:

score: 0
Accepted
time: 73ms
memory: 68152kb

input:

1751 1759 531008763
9647135396953811644272332744364825487141863132167864236389266835537272538297492381411517556352933112876776974316498866883849554132857457549895676665878549397367525393543799755297963856914869731913621112869781286648697173779522585373662577445465288265482227381973542199182249793724...

output:

120932314

result:

ok answer is '120932314'

Test #35:

score: 0
Accepted
time: 80ms
memory: 68216kb

input:

1807 1891 600092195
3579221958372986367746634695352276355235912155316655611692738781892955268975493718445949319317122398993719826627471161593654756186855972864613275624613878393778223993988769865242954196445511477564399715225325722212219796738143984819864248667769922598284917549533819159842154759387...

output:

515121580

result:

ok answer is '515121580'

Test #36:

score: 0
Accepted
time: 89ms
memory: 68096kb

input:

1787 1959 622796823
6278173249355881639817789934383263528288128476274555995915426743171597625145887184548877617626653815525698346351959364577241227792988895527541999385377297574771863852618425999759564558354741355119714779671766287234327344222591119325582619717693232132389814312572758178416315658142...

output:

219727190

result:

ok answer is '219727190'

Test #37:

score: 0
Accepted
time: 80ms
memory: 69364kb

input:

1773 1882 889998675
9354772767348998933324635459715386187863146987798139413825264356578165253223235789821573167483251955138715896147521721613714227597123423275451733198269155278737377543741843527334247324786438528229952866379452565476153522795918567898812337153429572285377988941239923342962848661839...

output:

393247125

result:

ok answer is '393247125'

Test #38:

score: 0
Accepted
time: 51ms
memory: 62784kb

input:

1605 1797 40639502
9+5+7+3+7+4+3+3+5+1+4+9+2+7+8+2+8+3+1+8+2+2+2+3+4+2+5+6+7+9+6+3+3+3+4+2+5+2+7+4+3+9+3+3+8+1+8+9+5+1+5+4+3+5+3+5+2+9+9+7+5+7+3+5+6+9+6+3+2+8+2+2+9+6+1+5+1+1+1+9+2+9+2+7+3+5+8+2+7+9+5+7+9+3+5+5+6+8+7+4+8+2+8+8+6+1+9+9+9+5+8+3+8+5+5+4+7+5+8+2+3+1+4+7+6+7+6+5+4+1+1+5+4+8+2+9+2+1+9+4+3...

output:

8242472

result:

ok answer is '8242472'

Test #39:

score: 0
Accepted
time: 77ms
memory: 67152kb

input:

1807 1737 482680433
4+4+1+9+5+2+5+6+9+7+6+4+2+5+6+7+3+8+1+2+3+5+7+4+2+8+5+3+3+2+1+5+9+9+3+5+7+3+6+2+5+9+9+3+8+4+8+1+8+3+1+8+2+9+6+9+9+6+5+9+9+8+8+7+8+8+7+6+1+7+1+7+9+7+6+9+1+1+1+4+6+9+8+5+4+4+6+6+1+1+1+8+6+9+4+5+8+3+6+7+7+5+4+5+5+1+3+2+3+3+8+7+6+2+4+2+3+2+5+7+1+7+4+8+2+9+6+8+1+6+5+5+6+7+1+8+3+6+7+4+...

output:

148606498

result:

ok answer is '148606498'

Test #40:

score: 0
Accepted
time: 67ms
memory: 69464kb

input:

1781 1951 112555066
3+8+8+9+5+9+9+5+1+5+1+2+8+1+9+8+7+9+4+2+3+1+9+1+7+5+1+3+1+5+2+4+1+2+5+5+6+6+3+5+4+8+4+4+7+1+2+3+4+9+8+4+4+4+9+4+8+1+9+1+4+4+1+9+9+1+3+4+7+2+9+8+6+5+1+1+4+1+7+5+7+7+3+7+1+4+3+2+6+1+1+6+1+8+9+6+7+4+8+4+4+4+5+6+2+7+5+8+7+6+6+3+3+8+2+6+3+5+7+7+9+8+6+1+1+8+2+7+4+6+6+6+9+4+7+5+4+9+7+5+...

output:

33767650

result:

ok answer is '33767650'

Test #41:

score: 0
Accepted
time: 51ms
memory: 66292kb

input:

1667 1717 158006109
8+7+6+4+6+8+7+3+3+8+1+8+5+8+1+6+7+6+6+3+8+7+3+8+2+1+1+8+2+4+8+2+2+4+2+4+6+8+2+3+2+2+3+8+5+4+4+2+7+3+2+4+5+1+2+9+3+5+6+6+3+3+5+3+9+2+2+9+9+8+7+6+8+4+9+4+1+9+8+8+3+7+6+3+4+9+6+2+6+7+5+1+3+7+9+6+5+2+5+8+6+3+6+4+5+9+6+1+2+9+6+5+2+1+5+6+1+6+3+9+6+9+4+5+1+9+3+2+9+2+5+1+4+9+4+4+9+5+2+8+...

output:

128597905

result:

ok answer is '128597905'

Test #42:

score: 0
Accepted
time: 77ms
memory: 69652kb

input:

1949 1887 301788882
7+6+2+4+8+3+7+5+3+5+1+5+9+1+1+5+4+2+3+7+2+5+3+8+2+1+5+9+6+4+6+1+1+7+3+5+3+8+2+4+7+7+6+8+4+8+2+6+1+1+1+2+2+9+1+1+8+8+4+3+3+2+1+8+9+6+1+8+4+6+6+2+8+2+3+5+4+5+9+5+3+9+3+6+6+8+5+5+1+5+7+2+2+4+6+5+5+8+1+4+4+3+4+2+1+2+2+4+7+8+4+9+3+2+4+4+3+8+1+6+6+5+3+6+1+1+7+7+3+1+4+6+9+7+9+1+8+2+2+3+...

output:

22050358

result:

ok answer is '22050358'

Test #43:

score: 0
Accepted
time: 73ms
memory: 68160kb

input:

1721 1824 626221639
95587298+1943+8542+476968914+56+19+338+24837+337+584+9728+5+36+613115+197+913198+215+7+12442145+681599+5485554+58+7561997591274712362+5+82+84+6+88999996954445475691788+586742729632723687+5588912+9822364+6286+3528+9281783+96271458+1674213556959695137+9+115+1+53+6+7+46852+3522+3617...

output:

184006446

result:

ok answer is '184006446'

Test #44:

score: 0
Accepted
time: 65ms
memory: 68252kb

input:

1765 1723 550818224
6+634+9+961+7118+455192223+9386+13479836689+56425682+838+4+263645149+117412659221+495+44474449+9174136743+941+95594237+51155+782+34+8487+721+19+24142+344381+8+489916+827235776554734977183851+3+9663259257171+99+98+399487+756175146+1935276689754+69+129995+78+355436+17+793732753+7+6...

output:

186182441

result:

ok answer is '186182441'

Test #45:

score: 0
Accepted
time: 83ms
memory: 69888kb

input:

1981 1701 185947343
58627465855+441+7+21+956+637+23+9+26394+32+789+476121747+5246+4346432873467+7916+4+63+5+6+571+548+325111537132+62671+33321+612154647+511+9735292+2315+2+353994685162699+754+53471426198978896924352+1+7+4+37+595+925558+96955872391898711776+2114+2368249966+579+593359782+556718458+89+...

output:

158362018

result:

ok answer is '158362018'

Test #46:

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

input:

1755 1703 295567983
128131+18596+314+218382+57+6253336+6422524693+5338938+5715282591368775+84745+7+44864+554772+292687+7824845+358634279697384114429+81+56+5+79892727256592727+66+4142545+4414838137118375+8215867278839277274446132137234698+4+7589789339+6775452188848+7+526839+539114+85+1+2716745424+186...

output:

240704463

result:

ok answer is '240704463'

Test #47:

score: 0
Accepted
time: 70ms
memory: 65136kb

input:

1662 1959 828244566
3712+8217533+5815526439+87122+22897228+9754+6+7+867776158+7819247+49+89+64866+368+36+1631523269+1+2416+2744+389+155648296439+36465114+9+41415+1229837889+2+37+596424266275632743+2+37+936394+911474476+7+69392668678+276+4+37589642582+612+4+4+35+2+74932+3449+5637+87624115415721539387...

output:

515404566

result:

ok answer is '515404566'

Test #48:

score: 0
Accepted
time: 69ms
memory: 69732kb

input:

1977 1679 300490479
3*4*8*8*4*3*5*1*7*6*8*7*5*5*5*4*9*5*4*3*5*1*6*1*5*3*7*1*7*1*7*6*6*7*4*7*7*5*6*8*5*5*6*8*7*8*8*3*2*3*9*4*1*4*5*2*8*1*7*1*7*2*4*9*5*2*2*5*2*7*3*8*2*4*6*9*6*7*9*9*7*1*4*4*8*3*2*4*1*8*8*4*9*4*9*4*2*7*9*6*8*8*4*5*1*1*8*4*5*6*2*9*3*5*2*1*1*5*7*2*2*8*9*7*2*3*3*3*7*9*7*9*9*1*1*5*1*2*6*5*...

output:

64743696

result:

ok answer is '64743696'

Test #49:

score: 0
Accepted
time: 63ms
memory: 67872kb

input:

1833 1603 123650286
2*4*1*3*8*8*2*1*4*2*8*9*2*2*3*1*2*2*5*3*6*6*9*4*7*3*6*9*9*3*3*7*1*3*1*6*4*2*2*7*8*4*3*3*1*9*2*1*8*5*5*6*6*9*1*8*8*5*1*3*2*1*3*6*3*5*4*4*5*2*8*2*6*4*1*6*9*8*9*6*8*8*9*3*4*2*6*7*1*4*5*7*3*4*4*4*7*6*4*2*7*2*7*2*3*9*4*6*3*5*5*3*5*7*7*6*1*5*3*9*5*2*2*3*1*2*5*8*1*9*2*4*1*9*5*2*9*6*4*8*...

output:

33642500

result:

ok answer is '33642500'

Test #50:

score: 0
Accepted
time: 73ms
memory: 65304kb

input:

1677 1935 732725013
5*5*9*2*7*8*3*7*7*9*6*2*2*5*5*9*6*4*8*1*8*6*1*2*9*2*6*9*2*1*7*5*3*8*2*5*8*6*6*3*9*6*6*1*9*3*3*6*4*5*6*1*6*8*4*6*8*5*1*9*9*3*5*2*7*6*6*4*3*2*6*2*9*6*2*9*8*7*8*4*9*4*3*5*1*9*7*6*2*9*5*9*3*5*2*5*9*3*3*9*9*2*5*9*8*4*6*2*9*8*8*7*2*6*4*8*1*6*5*3*8*9*6*3*9*7*2*5*2*9*3*7*9*3*6*6*4*6*6*8*...

output:

307697792

result:

ok answer is '307697792'

Test #51:

score: 0
Accepted
time: 57ms
memory: 67988kb

input:

1805 1627 332517332
2*3*6*7*7*3*6*1*9*3*2*2*2*1*8*2*2*8*9*2*4*9*2*6*5*1*8*4*7*4*8*6*2*5*9*5*8*5*2*9*7*4*5*4*7*4*3*6*4*7*4*9*4*8*5*2*7*2*6*2*3*2*2*1*3*4*4*2*4*9*7*5*8*1*2*3*8*7*9*9*6*9*4*9*7*5*3*9*7*5*5*2*8*3*4*6*6*1*3*6*7*5*5*4*9*2*5*9*5*2*8*2*4*9*5*9*2*8*2*8*1*5*7*8*8*2*5*1*9*9*9*2*6*2*2*9*8*3*4*4*...

output:

305061664

result:

ok answer is '305061664'

Test #52:

score: 0
Accepted
time: 59ms
memory: 66204kb

input:

1709 1659 504006210
1*5*7*6*8*6*8*1*2*5*5*5*8*1*3*2*7*8*1*5*5*9*2*5*2*6*4*1*2*3*5*3*4*9*2*4*4*7*5*9*1*9*7*7*6*3*3*9*7*4*1*7*1*9*6*3*1*1*5*8*8*2*5*2*1*2*6*7*1*3*2*8*1*3*8*6*1*2*5*6*4*3*7*7*2*3*5*6*3*3*1*9*2*8*3*3*7*1*5*9*1*1*2*2*4*3*2*4*2*8*4*9*4*1*1*2*2*4*8*8*8*4*3*1*3*4*8*1*5*6*7*3*3*4*4*7*7*9*7*4*...

output:

331900440

result:

ok answer is '331900440'

Test #53:

score: 0
Accepted
time: 75ms
memory: 68308kb

input:

1747 1853 541632006
8298676527446*6*6*27743477233*939*631758*11265*61*992*47961494537567*63926*6*927299*9586*2*16148*2221232*63*7997117657194*563721*349196*9*4696156*72167*416439422*93*1*58554347412669469761*3*78*17964*973694*799*6643*33215*4499749*2868*4*2323*58*75694*4753797647*78*677*56945797*3*7...

output:

201705673

result:

ok answer is '201705673'

Test #54:

score: 0
Accepted
time: 83ms
memory: 69228kb

input:

1932 1648 715104954
529332*985*4447825971687547*51243*51253*6*67*1829181838164*86128659767*6*217*937*58818*6*7468816*91*4268*5*522923669728458746*3*54424884*9*5563249*152326*4*3372371*17*7*71*151*8492924654*8127*6298*5*7*59*872*642*98536887*17*733*27657*27628356987*4832849*2159*9*8*151236378*5*24*9*...

output:

153001710

result:

ok answer is '153001710'

Test #55:

score: 0
Accepted
time: 80ms
memory: 70008kb

input:

1902 1908 83055669
924768977222*441*7855935*2311126347123128*73*31914*1*832*6*89*422*235855*84864*2682422*44595157*7786683332616*1271527398*242111669848968466765466591692995*9*66857419*3*869*2487681*3196855612567697*8*7648*4*295*974158377586159*9*78*7139*2885*1*65*81*64*61326434618*85*814*354113*36*...

output:

69002874

result:

ok answer is '69002874'

Test #56:

score: 0
Accepted
time: 73ms
memory: 65248kb

input:

1686 1823 679314554
9*6422343*132231725*578152271*9361384*73*896875698939642915*582768*21335298158732*9*656791937266*329*55*3*1266548966519369*44*6*2*749981942959841262*8*917*853853*61717574583145*63475267677579*42446919611434926891797*441*2784*632936*4219*663*7*61388712874125177*5*229*111*98*49*6*2...

output:

563494096

result:

ok answer is '563494096'

Test #57:

score: 0
Accepted
time: 84ms
memory: 65028kb

input:

1679 1865 783440322
355*598982*78*57828964*32*29532*6*39*88353*98611*238*24329887447711654*361*2242538*3944*86594782834*7776874667396185535*1*14294443973474*89295*14452783271*6*672*995368293*378872*255*5377395686*8634*263*9*28*74323186822*17981879155657*8*7929691*4*283793493*89429787*2943*1*7*49336*...

output:

202587984

result:

ok answer is '202587984'

Test #58:

score: 0
Accepted
time: 66ms
memory: 68412kb

input:

1694 1864 11895225
833549136724636371+8552133*63552+39936416518497984124149255*4+211474287+622764541+12711142+23622455785*517712791*5*2+16766686835165186895711+1922437734788761*4*528927642918753439767796379356972+97466*6371241392817*782822311672572938468359349393968484+731845187999667*36933167282633...

output:

4955064

result:

ok answer is '4955064'

Test #59:

score: 0
Accepted
time: 78ms
memory: 64720kb

input:

1628 1998 522878509
44+2967*9182318178724482885679974891122112+349526178517378889642+8664826553*15728146864+45834763919749346622477+912798815+89189795244913525157+115464887734219776534213686288144685277149+98882913897*8318164453592649459311976+432838945129427369351763351465785624324853*4627313957149...

output:

75104427

result:

ok answer is '75104427'

Test #60:

score: 0
Accepted
time: 74ms
memory: 61992kb

input:

1618 1678 532822336
769+2388823859217427311661574789431312388228636993674*51748534+627312674495187871+1389256352446825755*381*2555313231658*7245+9277*9*51554891459547874142363995217292371*85754978398194185+55335775373*71728943519821142814353897+736365175765666612167255886*46492457*2+9563+45575821747...

output:

389405463

result:

ok answer is '389405463'

Test #61:

score: 0
Accepted
time: 65ms
memory: 64772kb

input:

1672 1608 23286546
2949*63825839494176191*914+9923467337798531461667214283149676753953*77269883935889*515754789471668234565638733865527888281+124321338663+7157258*8756332818357124966*657985236843617325238898*3757359234434125627*891+5413+763341196798983771279918947473686314484*36758753733183316561916...

output:

8366352

result:

ok answer is '8366352'

Test #62:

score: 0
Accepted
time: 68ms
memory: 66272kb

input:

1767 1648 978358115
213553+394959145666232867946527317295134553439243266544842371*52682628866+26+45416928535495199421268+7774111293*415899688562941+74455779194773959766668476178915746531363357826913449+288767494698536567513373882+5519575958948+77275844+2+41345142897488162599113+991229811713882738329...

output:

513604040

result:

ok answer is '513604040'

Test #63:

score: 0
Accepted
time: 79ms
memory: 66700kb

input:

1663 1987 482323882
596372126946364188365162286975+7198567779577592841*7937*74446981554741138318733388995*977*5774924231416269473842482228113376756*68127916279247369898655124971618367532195237343746128341485619+524584156727526+73*8529+7288258594891872466466559828831739912687324+964371226321995812935...

output:

442210421

result:

ok answer is '442210421'

Test #64:

score: 0
Accepted
time: 65ms
memory: 66720kb

input:

1734 1789 209237839
79432366948*35899977494653278122366*5882998755577915132+7977126715655177*587+895972415647396841567128276876559*42869*5183795331451685141366472428+572677883949733729359311*55668437215844678886996634+688+545328331*66815152653496939992175144614177373229542568372577348217+89719791525...

output:

108066950

result:

ok answer is '108066950'

Test #65:

score: 0
Accepted
time: 83ms
memory: 69884kb

input:

1936 1962 839460171
7893657236948685539196283687629816832558632492975*7876714338466684593726999124571484637159651883874728594+9814435396892658367+534991989984564525454875299912859767449*7773814649929641521611479823847849814+632*7815179982961523782579759219327841383725664+9727453513*25376141983685944...

output:

479096397

result:

ok answer is '479096397'

Test #66:

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

input:

1783 1951 177645362
937588725774*1114845+246589211454*6476*441*28*524497232*38265+298446*732+726292154169567814271417373913449712614411*7331371*86174371396+7474351+53448475451*6815318445253445527*25692789189513+548272*4992484311864742+42128141254797492182952274565225*699936686115191378*2733527581+44...

output:

65370074

result:

ok answer is '65370074'

Test #67:

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

input:

1933 1740 732129146
673222898*685761642781722167171933234973966*84922681455963713615*44819169512375916397883487513+22593654163*71539715348643677777241128118782*94933795977575215529823253358762813449951578226288317964991833856696*469917127291136+49266116885221568626691+88222244932+6223171545537883641...

output:

362723158

result:

ok answer is '362723158'

Test #68:

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

input:

1 1595 582357881
5515841464123223388972478744227778238467443168968928497782774388556338418342813529787477528363381634167177212395899727855729129169966679487423838684631533317467151118329667772622815147437627972487859818761783921862774914616629674517326346877677835285452819513434886138194322166297369...

output:

376819647

result:

ok answer is '376819647'

Test #69:

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

input:

465 1 579024518
1
9
6
6
7
2
1
2
8
3
4
1
*
5
1
+
4
5
6
8
6
4
+
3
4
7
*
3
1
6
5
9
1
8
7
5
8
2
8
2
+
9
1
5
4
8
2
7
6
3
9
9
8
9
2
6
+
5
8
5
+
8
6
2
3
7
7
9
4
6
8
3
3
9
5
9
7
3
7
6
8
8
8
5
*
6
3
6
9
1
9
9
*
1
3
5
1
3
9
9
4
8
2
6
4
9
3
4
4
1
5
5
9
3
1
1
9
7
+
4
4
+
9
*
2
6
3
*
6
6
1
+
9
7
9
9
2
4
3
3
5
7
...

output:

365092841

result:

ok answer is '365092841'

Test #70:

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

input:

325 1 652182157
5
4
8
5
+
1
+
3
4
1
8
6
+
2
6
1
8
9
8
1
7
9
9
4
8
4
5
8
8
1
5
1
4
7
9
6
5
2
6
8
5
4
9
3
1
3
2
8
2
+
1
1
8
3
6
6
6
6
4
3
9
1
9
9
4
8
7
1
5
1
5
8
1
8
4
8
9
5
7
8
5
6
1
4
1
4
3
5
2
4
8
1
1
9
7
1
6
7
8
4
4
4
6
5
+
4
4
1
8
8
8
+
1
4
6
3
2
5
2
5
6
8
6
5
6
1
1
5
1
8
2
3
8
4
+
8
9
2
5
+
4
6
...

output:

323142860

result:

ok answer is '323142860'

Test #71:

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

input:

1640 1 386576039
3
4
7
2
5
4
6
9
7
4
6
+
9
6
4
3
3
3
3
+
1
4
1
4
4
4
8
2
4
2
7
9
8
1
6
+
7
2
4
5
7
1
9
6
5
3
2
4
2
1
4
+
9
4
7
2
7
1
9
4
5
1
7
2
7
5
2
9
5
6
2
6
5
6
+
5
3
4
4
+
4
5
7
+
3
4
4
8
6
+
9
4
9
4
6
1
1
4
2
+
2
3
6
1
7
7
9
4
6
8
4
+
8
1
+
9
3
5
5
9
4
1
7
9
5
3
+
6
8
6
8
7
1
6
8
8
9
2
8
6
2
6...

output:

336296499

result:

ok answer is '336296499'

Test #72:

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

input:

1865 1 679091098
7
*
5
7
4
2
*
5
4
9
7
*
2
8
3
4
*
6
3
1
5
1
7
*
4
2
3
5
7
7
9
6
7
4
7
8
9
3
7
5
4
2
9
*
6
7
4
7
2
2
1
5
8
8
1
7
2
4
*
5
7
1
5
8
7
4
3
2
7
4
3
3
1
3
7
*
2
7
6
4
2
7
2
5
2
7
7
9
*
4
5
3
8
*
2
7
4
1
6
*
3
6
4
9
3
1
1
5
8
6
1
6
2
1
5
7
7
5
9
7
6
9
9
7
1
1
2
2
1
8
2
7
1
7
7
2
1
1
2
5
3
6...

output:

101634036

result:

ok answer is '101634036'

Test #73:

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

input:

43 1 213251012
1
5
1
9
8
7
2
8
*
3
2
9
2
1
6
2
2
8
*
4
7
+
7
4
9
4
4
1
5
6
1
*
7
7
8
2
+
9
3
+
4
7
8

output:

193840749

result:

ok answer is '193840749'

Test #74:

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

input:

685 1 442080746
7
*
7
1
3
3
2
1
9
6
*
6
3
7
8
7
9
5
7
6
6
4
9
5
6
9
1
6
8
2
6
7
5
9
3
6
2
7
9
1
9
7
*
6
6
5
9
5
*
4
4
7
9
9
3
1
4
2
7
7
8
*
9
1
1
8
2
1
9
4
9
5
1
5
6
2
5
2
*
7
8
6
*
2
6
2
7
9
3
3
9
3
1
3
2
9
2
5
4
9
4
1
6
9
1
3
2
9
3
9
5
3
6
2
2
9
3
9
6
*
1
4
2
8
7
*
7
8
5
4
9
5
1
9
1
8
5
9
8
4
*
9
...

output:

377506544

result:

ok answer is '377506544'

Test #75:

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

input:

1 1183 825086068
7781374775*14644142497344713595558299*981783897461733535466477968*756431684*4583582*41236391*558682649876386233*42249481275555711381737*5*551476947638651859615*92*362675*83584*59222*8528458823637*4543452358587646*926654414953194338*994*28*6*1531578575554851*9491264195*827958946246*8...

output:

779133616

result:

ok answer is '779133616'

Test #76:

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

input:

625 1 681324822
9
9
5
2
8
3
7
3
5
9
8
4
9
8
2
7
5
9
9
4
4
3
1
8
1
3
6
8
7
2
7
8
6
5
1
7
5
3
1
1
9
5
3
9
4
8
7
6
1
8
5
5
7
4
2
4
1
5
4
8
9
6
9
8
1
1
5
1
5
2
6
7
1
5
3
5
9
1
4
1
5
8
3
6
3
3
4
6
6
6
6
8
9
5
8
5
9
2
2
6
1
4
9
9
9
3
8
9
9
4
9
5
1
5
2
5
2
2
1
8
3
1
1
1
6
6
5
9
7
4
3
1
1
1
3
8
5
5
5
5
5
4
...

output:

324777552

result:

ok answer is '324777552'

Test #77:

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

input:

1774 1 993316015
3
1
3
5
9
9
1
8
7
6
8
9
9
7
*
7
5
6
6
4
1
5
4
6
+
1
7
7
1
2
1
4
+
5
+
7
4
9
8
*
2
3
1
+
3
+
2
5
4
5
5
+
7
6
4
7
3
+
7
3
1
3
1
*
2
2
2
9
1
8
8
+
2
1
1
2
5
+
3
+
2
6
5
8
1
1
4
*
6
7
6
4
3
4
8
8
4
5
*
8
5
7
4
7
4
3
4
3
2
2
6
+
3
1
+
7
4
4
3
4
2
5
9
6
9
2
8
7
5
5
2
3
6
6
+
7
3
8
5
2
+
2...

output:

834279995

result:

ok answer is '834279995'

Test #78:

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

input:

1 1 8
8

output:

0

result:

ok answer is '0'

Test #79:

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

input:

1 2 12
12

output:

0

result:

ok answer is '0'

Test #80:

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

input:

10 1 1000000000
1
1
1
1
1
1
1
1
1
1

output:

111111111

result:

ok answer is '111111111'