-Code
def convert(N, base):
nums = "0123456789ABCDEF"
answer = ""
while N > 0:
answer += nums[N % base]
N //= base
return answer[::-1]
for _ in range(int(input())):
a, n = map(int, input().split())
res = convert(a, n)
print(1 if res == res[::-1] else 0)
10진법 이상일 경우를 생각 못해서 시간이 좀 걸렸습니다.
'Beakjoon&프로그래머스 > 파이썬' 카테고리의 다른 글
[백준/파이썬] 14915번 진수 변환기 (0) | 2022.07.07 |
---|---|
[백준/파이썬] 10205번 헤라클레스와 히드라 (0) | 2022.07.06 |
[백준/파이썬] 13420번 사칙연산 (0) | 2022.07.04 |
[백준/파이썬] 7482번 상자 만들기 (0) | 2022.07.03 |
[백준/파이썬] 8949번 대충 더해 (0) | 2022.07.02 |