dict1={'M':1000,'CM':900,'D':500,'CD':400,'C':100,'XC':90,'L':50,'XL':40,'X':10,'IX':9,'V':5,'IV':4,'I':1}while 1 :list1=list(map(str,input().split()))s=''num=pnum=snum=0if '#' in list1:breakelse:for i in list1[0]:pnum+=int(dict1.get(f'{i}'))for f in list1[1]:snum+=int(dict1.get(f'{f}'))num=pnum-snumif num ==0:print('ZERO')else:for g,v in dict1.items():while num>=v:num-=vs+=gprint(s)
for i in list1[0]: pnum+=int(dict1.get(f'{i}')) for f in list1[1]: snum+=int(dict1.get(f'{f}'))
這兩行有誤。在輸入時要考慮有減法的情況。
例IV I,答案很明顯的是III,但程式跑出來的是V