QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#772336 | #9555. Strength | Chen_jr | WA | 131ms | 3956kb | C++14 | 1.7kb | 2024-11-22 18:50:11 | 2024-11-22 18:50:11 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int bx[22], bz[22];
ll f[22][2][3];
void solve(){
memset(bx, 0, sizeof(bx));
memset(bz, 0, sizeof(bz));
memset(f, 0, sizeof(f));
ll x, z;
scanf("%lld%lld",&x,&z);
int cntx = 0, cntz = 0;
while(x)bx[++cntx] = x % 10, x /= 10;
while(z)bz[++cntz] = z % 10, z /= 10;
if(bx[1] == 0){
for(int i = 0; i <= 4; ++i)++f[1][i > bz[1]][0];
for(int i = 5; i <= 9; ++i)++f[1][i > bz[1]][1];
}else f[1][bx[1] > bz[1]][0] = 1;
cntz = max(cntz, cntx);
for(int i = 2; i <= cntz; ++i){
for(int upper = 0; upper <= 1; ++upper){
for(int j = 0; j <= 9; ++j){
int s = ((j > bz[i]) || (j == bz[i] && upper));
if(bx[i] == 0){
f[i][s][0] += (j < 4) * (f[i - 1][upper][0] + f[i - 1][upper][1] + f[i - 1][upper][2]) + (j == 4) * f[i - 1][upper][0];
f[i][s][1] += (j >= 5) * (f[i - 1][upper][0] + f[i - 1][upper][1] + f[i - 1][upper][2]);
f[i][s][2] += (j == 4) * (f[i - 1][upper][1] + f[i - 1][upper][2]);
}else if(bx[i] == 1){
f[i][s][0] += (j <= 4) * (f[i - 1][upper][1] + f[i - 1][upper][2]) + (j == 1) * f[i - 1][upper][0];
f[i][s][1] += (j >= 5) * (f[i - 1][upper][1] + f[i - 1][upper][2]);
}else{
f[i][s][0] += (j == bx[i]) * (f[i - 1][upper][0] + f[i - 1][upper][2]) + (j == bx[i] - 1) * (f[i - 1][upper][1] + f[i - 1][upper][2]);
}
}
}
// printf("i = %d %lld %lld %lld %lld %lld %lld\n",i, f[i][0][0], f[i][0][1], f[i][0][2],f[i][1][0], f[i][1][1], f[i][1][2]);
}
printf("%lld\n",f[cntz][0][0] + f[cntz][0][1] + f[cntz][0][2]);
}
int main(){
int T; scanf("%d",&T);
for(int i = 1; i <= T; ++i)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
input:
5 0 2147483646 10 100 671232353 1232363 123001006660996 3122507962333010 100019990010301090 44519984489341188
output:
2147483647 55 0 1919810 114514
result:
ok 5 number(s): "2147483647 55 0 1919810 114514"
Test #2:
score: 0
Accepted
time: 107ms
memory: 3956kb
input:
100000 983802844195390320 867841388828035681 561712225511657823 824804699460484241 404870597011321334 620779795945179144 108290710733586980 71448325262443207 554396372532342266 866274696506270783 825413569026587006 463721160356652294 954854657812169407 863877305870296520 93529650461135145 7224482112...
output:
0 1 1000 11000 1 0 0 70 100 1 0 100 0 20 0 0 0 0 100 1050 0 0 10 5500 0 100 0 0 0 100 100 59500 1 1 10 100 0 0 0 10 0 100 10 0 100 0 10 10 0 0 0 10500 10 100 10 0 100 0 1000 10 24 1000 1000 0 0 700 0 1000 0 0 100 10 1 0 5000 10 10 0 700 10 1 0 10 0 105 1 100 5500 1 0 100 0 0 10 29012500 100 80 0 700...
result:
ok 100000 numbers
Test #3:
score: 0
Accepted
time: 116ms
memory: 3772kb
input:
100000 100100101001001000 241871790564461103 100100101001001000 855661147750661961 100100101001001000 896900243135796267 100100101001001000 513783969315243904 100100101001001000 534089128945830920 100100101001001000 855891455712467272 100100101001001000 822769449458940477 100100101001001000 27261267...
output:
11860893750000000 38098223671547687 41245349574000000 24555351037500000 24555351037500000 38116205315377100 37249808325000000 14004190260375000 41481294087500000 37003490797725000 19303614665193816 37249808325000000 42802278849438610 41481294087500000 11860893750000000 16092379512500000 287868368000...
result:
ok 100000 numbers
Test #4:
score: 0
Accepted
time: 131ms
memory: 3908kb
input:
100000 1000000000000000000 957512997968887619 1000000000000000000 922920507238342609 1000000000000000000 990971169138689806 1000000000000000000 934649579477343310 1000000000000000000 999730660108208312 1000000000000000000 954708096872168078 1000000000000000000 979183786117650947 1000000000000000000 ...
output:
513068553524443175 478476062793898165 546526724694245362 490205135032898866 555286215663763868 510263652427723634 534739341673206503 529490458837542795 548664760129928238 472781619229996635 485184360746792321 538707030787093693 553991590885355836 486831442281292050 547039286480320752 516609820897215...
result:
ok 100000 numbers
Test #5:
score: 0
Accepted
time: 122ms
memory: 3884kb
input:
100000 0 881341937719391917 0 431276023192975575 0 592093852964812925 0 525654467861191536 0 347546572239293150 0 392443921633282269 0 974615659937363980 0 300345267050133863 0 804808864588612719 0 457764914216738214 0 802598193341206286 0 896184349672589101 0 963089045250048537 0 904903069044744433...
output:
881341937719391918 431276023192975576 592093852964812926 525654467861191537 347546572239293151 392443921633282270 974615659937363981 300345267050133864 804808864588612720 457764914216738215 802598193341206287 896184349672589102 963089045250048538 904903069044744434 996049320107955042 888770207398768...
result:
ok 100000 numbers
Test #6:
score: 0
Accepted
time: 115ms
memory: 3768kb
input:
100000 665168278 546178179932029377 66635116 867921505309634958 945310561 763196012741110977 717637962 742714965215556053 130000097 900963704818491245 513285041 564473154943477861 543677531 60404054788269644 367645182 357106974071909901 115338905 825374015292361415 896431772 8744958006264556 9768187...
output:
546178180 8679215053 41975780660 742714965 95101223881275 5644731550 60404055 357106974 8253740160 8744958 329923473 753921331 514991507 19192934255 342259638 838797957000 824968218 35848926905 711824564 9870284580 8371974180 8281366300 84708006915 309691421 73662888430 3793642780 299294217556125 57...
result:
ok 100000 numbers
Test #7:
score: 0
Accepted
time: 103ms
memory: 3900kb
input:
100000 947850020979955040 543166942 829073435881783314 604005775 618853000395699868 996237784 359727808408688277 182691791 849530805599047150 112670250 332125482592360629 545024060 698871296075568948 664733840 81132957574234141 714741961 618898907861742327 348120143 436291197216861986 180370984 1600...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 numbers
Test #8:
score: 0
Accepted
time: 130ms
memory: 3828kb
input:
100000 10100001001010000 983338066775728921 111100100 938800861716174893 11000101010000 972245555533536920 11000100100000010 963044043689781898 1100000001100010 995749506737729716 10111000000100000 939790937268044435 1000110001100 931378292560777605 10101101000000000 995606363318456725 1111010000000...
output:
74106824855000000 43552380177098000 63277549994799750 59088263257000000 52628739205531150 52153223412500000 53165003351680000 63428022168497000 44362748295738600 65635840639402500 9667230545735000 63602982034790000 47652113709492825 55752233488675000 326394444440000 12220934552807500 125711989091940...
result:
ok 100000 numbers
Test #9:
score: 0
Accepted
time: 129ms
memory: 3892kb
input:
100000 11101000011011011 926451601330317554 100111011101011000 980012799654355014 10010111010111100 914365178504925535 11000101110111010 966353984753480197 11111001100011100 922945224790939327 1010101110101101 947277280713827870 100010111110101001 932003598416345188 11011100110011100 916620779266892...
output:
72936871393750 2482705916562500 2267184102259125 2275988792312500 1733479709567500 495686697500000 434130449900000 2085219287052250 407138035035050 2081792339862500 2643199102500000 2255791518487500 76626957848750 452752715950000 73514333965000 15447635040000 1981531400687500 489013506125000 9310973...
result:
ok 100000 numbers
Test #10:
score: 0
Accepted
time: 124ms
memory: 3908kb
input:
100000 111011011111111010 938034739545618565 111110101011110111 942870184217416845 111111011011111010 953878301421487782 11111010101111111 952117476620803296 11101111010111111 985861618102878890 110011111111110101 936313724389267468 101001111111101111 913504177411108465 111111111001011101 9546642396...
output:
111715673887500 858389355000 111889114043750 1192503750 6341489750 18567626603750 141362264750 18408957906000 19479107207500 18964892528000 175421471250 99310122999750 3821177566125 19490669395000 3801779246750 761442660500 22487720512500 252998750 18349720167500 100964710513000 111715673887500 3040...
result:
ok 100000 numbers
Test #11:
score: 0
Accepted
time: 119ms
memory: 3952kb
input:
100000 90900009009090000 983338066775728921 999900900 938800861716174893 99000909090000 972245555533536920 99000900900000090 963044043689781898 9900000009900090 995749506737729716 90999000000900000 939790937268044435 9000990009900 931378292560777605 90909909000000000 995606363318456725 9999090000000...
output:
10528058362500 10350279492525 10825957405000 10523619461250 11024749419750 10027719722250 10884699989625 10555555550000 10154444439100 11136110525000 10643873100000 11754103413750 10941466090800 10523624446125 9032153991220 11663070496875 11049748093125 11017661484225 10991283817500 11083333327500 1...
result:
ok 100000 numbers
Test #12:
score: 0
Accepted
time: 121ms
memory: 3896kb
input:
100000 99909000099099099 926451601330317554 900999099909099000 980012799654355014 90090999090999900 914365178504925535 99000909990999090 966353984753480197 99999009900099900 922945224790939327 9090909990909909 947277280713827870 900090999990909009 932003598416345188 99099900990099900 916620779266892...
output:
94995000 110775000 99225000 94950000 104682375 94000000 91875000 104186250 0 0 78750000 94950000 99697500 0 94995000 99697500 104445000 94500000 115762500 94999500 116368875 115762500 104499450 0 0 103120500 0 100065000 94999500 94950000 0 110775000 104445000 96810000 99225000 110775000 0 0 10363500...
result:
ok 100000 numbers
Test #13:
score: 0
Accepted
time: 111ms
memory: 3956kb
input:
100000 999090999999999090 999999999999998094 990999990909999099 999999999999997336 999990099990990999 999999999999997779 90999999990999990 999999999999992536 999999090099999099 999999999999995506 999990999090909999 999999999999996192 900999909999999909 999999999999995220 909099999099999990 999999999...
output:
10000 10000 10500 10000 10500 10000 10500 10000 10500 10500 10500 10000 10000 10500 10000 10000 10000 10550 10000 10500 10000 10000 10500 10500 10500 10500 10500 10000 10500 10500 10000 10500 10000 10500 10000 10500 10500 10000 10500 10000 10500 10500 10000 10500 10500 10500 10500 10500 10550 10550 ...
result:
ok 100000 numbers
Test #14:
score: -100
Wrong Answer
time: 28ms
memory: 3952kb
input:
100000 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 59 0 6...
output:
0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
wrong answer 1st numbers differ - expected: '1', found: '0'