a = list(input()) # a를 리스트 형식으로 입력받기
b = list(input()) # b를 리스트 형식으로 입력받기

if len(a) == 1 and len(b) == 1 : # 한 글자리 처리
    print(int(a[0]) - int(b[0])) # 빨리 끝내기
    exit()

c=[] # c 선언 참고: 애가 계산 최종본
r=0 #r선언

if len(a) < len(b): # b가 a보다 클때 설정
    temp = a.copy()# temp로 a 저장
    a = b.copy() # b를 a자리로 설정후 나중에 - 붙일 예정
    b = temp.copy()
    r=1

elif len(a) == len(b):
    for i in range(len()):# 다른 방식b가 a보다 클때 설정
        temp = a.copy() # temp로 a 저장
        a = b.copy() # b를 a자리로 설정후 나중에 - 붙일 예정
        b = temp.copy()
    r=1
t=0


num=0
# while len(a) != 0 and len(b) != 0: # 다 지우면 끝내기
#     if len(b) == 0:#만약 b가 0이면 - 할게 없기에 그냥 넣기
#         c.append(a.pop())# c에 넣기
#         continue#넘기기
#         print("1")
#          # 여기가 잘못된듯
#     elif int(a[len(a)-1]) < int(b[len(b)-1]) and len(a) >= 2:# 받아올림!
#         num = int(a.pop())+10 - int(b.pop()) # 계산한거 임시로 넣기
#         t=1
#         print("2")
#     elif t==1:
#         print("3")
#         c.append(num-1)
#         t=0
#         continue
#     else: # 평법한 계산
#         print("4")
#         num = int(a.pop()) - int(b.pop())
#     c.append(num) # 계산 값 넣기
while len(a) != 0 and len(b) != 0: # 다 지우면 끝내기
    if len(b) == 0:#만약 b가 0이면 - 할게 없기에 그냥 넣기
        c.append(a.pop())# c에 넣기
        continue#넘기기
        print("1")
    if num<0:
        temp=c.pop()
        c.append(temp-1)
        num =int(a.pop())-int(b.pop())-1
        
    else: 
        num= int(a.pop())-int(b.pop())
    c.append(num) # 계산 값 넣기



while len(c) != 1: # 맨 앞에 있는 게 0이면 지우기
    if c[0] == 0:
        c.pop(0)
    else:
        break

if len(c) == 0:# 만약 a,b가 같았다면 0출력하고 나가기
    print("0")
    exit()

if r == 1: # 마이너스인 경우 앞에 - 붙이기
    print("-",end='')

for i in range(len(c)):# 결과 값 출력
    print(c.pop(),end='')








Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: