python-algorithm
백준 6976 Divisibility by 11
무적김두칠
2022. 12. 7. 10:17
https://www.acmicpc.net/problem/6976
6976번: Divisibility by 11
For each positive integer in the input, the output consists of a series of numbers formed as a digit is deleted and subtracted, followed by a message indicating whether or not the original number is divisible by 11. Outputs for different positive integers
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
def sol(n):
start_num = n
while n>=100:
print(n)
n = n//10 - n%10
print(n)
if n % 11 == 0:
print('The number %d is divisible by 11.'%(start_num))
else:
print('The number %d is not divisible by 11.' % (start_num))
if __name__ == '__main__':
t = int(input())
for _ in range(t):
n = int(input())
sol(n)
if _ != t-1:
print()
|
cs |
반응형