

-Code
for _ in range(int(input())):
arr = []
k, b, n = map(int, input().split())
while n:
arr.append(n % b)
n //= b
res = 0
for a in arr:
res += a ** 2
print(k, res)
'Beakjoon&프로그래머스 > 파이썬' 카테고리의 다른 글
[백준/파이썬] 24073번 ビ太郎と IOI (Bitaro and IOI) (0) | 2023.07.07 |
---|---|
[백준/파이썬] 17851번 This Problem’s a Slam Dunk (0) | 2023.07.06 |
[selenium] find_element_by_* (0) | 2023.07.04 |
[백준/파이썬] 24089번 ボールの移動 (Moving Balls) (0) | 2023.07.04 |
[백준/파이썬] 24074번 分割 (Split) (0) | 2023.07.03 |