꾸준히 합시다

백준 파이썬 3486번: Adding Reversed Numbers 본문

코딩 테스트 문제 풀이

백준 파이썬 3486번: Adding Reversed Numbers

tturbo0824 2021. 6. 12. 14:05

https://www.acmicpc.net/problem/3486

 

3486번: Adding Reversed Numbers

The Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Therefore the dramatic advisor of ACM has decided to transfigure some tragedies into comedies. Obviously, this work is very hard beca

www.acmicpc.net

문제 유형: 수학, 구현, 사칙연산

 

 

# Solution 1

import sys
input = sys.stdin.readline

def newNum(num):
    num = list(num)
    while num[-1] == "0":
        del num[-1]
    return int(''.join(num)[::-1])
        
for _ in range(int(input())):
    n, m = map(str, input().split())
    
    answer = newNum(n) + newNum(m)
    print(newNum(str(answer)))
Comments