QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#363627#7698. ISBN Conversionpipoika#WA 10ms9520kbPython3827b2024-03-24 01:06:302024-03-24 01:06:30

Judging History

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

  • [2024-03-24 01:06:30]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:9520kb
  • [2024-03-24 01:06:30]
  • 提交

answer

INV='invalid'
def r():
    w=input()
    # print(w)
    if '--' in w:return INV
    if w[0]=='-' or w[-1]=='-':return INV
    # print('here')
    dc = w.count('-')
    if dc>3:return INV
    if dc==3 and w[-2]!='-':return INV
    if w.count('X')>1:return INV
    if w.count('X')==1 and w[-1]!='X':return INV
    if len(w)-dc!=10:return INV
    digs=''.join(c for c in w if c!='-')
    digs=digs[:-1]
    digs=list(map(int,digs))
    s10=0
    for i in range(len(digs)):
        s10+=digs[i]*(10-i)
    s10=11-(s10%11)
    if s10==10:
        s10='X'
    else: s10=str(s10)
    if w[-1]!=s10:return INV
    digs=[9,7,8]+digs

    s=0
    for i in range(len(digs)):
        s+=(1+2*(i%2))*digs[i]
    s=10-(s%10)

    return '978-'+w[:-1]+str(s)


for _ in range(int(input())):
    print(r())

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 9420kb

input:

4
3-540-4258-02
039428013X
3-540-42580-2
0-14-028333-3

output:

invalid
978-0394280134
978-3-540-42580-9
invalid

result:

ok 4 lines

Test #2:

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

input:

25
----------
-----------
------------
-------------
XXXXXXXXXX
XXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXXX
---------X
----------X
-----------X
01234567890
012345678901
0123456789012
-0123456789-
0123456789-
-0123456789
01--23456789
012345678--9
0123456789--
--0123456789
98765432-1
987-654-321
87-645-32-...

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

ok 25 lines

Test #3:

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

input:

5
71234567X1
71234567X-1
2-2345678-9
8X-7X-123456
7123X8123X

output:

invalid
invalid
invalid
invalid
invalid

result:

ok 5 lines

Test #4:

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

input:

10
3-540-42580-X
3-540-42580-3
0393609394
0-19-853453-9
0070131510
0070131512
0070131514
0070131516
0070131518
007013151X

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

ok 10 lines

Test #5:

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

input:

11
767-13423100
65955-01-15-1
778592-4222
3283-138-073
8-802896-37-4
514-2481525
356-52708-6-6
4-810-73599-7
3-28438-244-8
1-98-2031209
82-54-55344X

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

ok 11 lines

Test #6:

score: 0
Accepted
time: 4ms
memory: 9400kb

input:

12
0123456789
0-19-853453-1
0070131511
0-07-0131511
039428013-X
0-39-428013X
0-3942801-3X
0131103628
3-540-42580-2
3540425802
1535956828
1535-9-5682-8

output:

978-0123456786
978-0-19-853453-2
978-0070131514
978-0-07-0131514
978-039428013-4
978-0-39-4280134
978-0-3942801-34
978-0131103627
978-3-540-42580-9
978-3540425809
978-1535956826
978-1535-9-5682-6

result:

ok 12 lines

Test #7:

score: -100
Wrong Answer
time: 5ms
memory: 9480kb

input:

10
69289-01810
07-8-2406750
4946302-980
91-45-00652-0
2526831830
8370591930
022-18967-4-0
86340-22-25-0
862-57-6642-0
1691783730

output:

invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid

result:

wrong answer 1st lines differ - expected: '978-69289-01810', found: 'invalid'