IDEA
直接暴力循环。
Code
Python
def check_num(num):str_num = str(num)# 先判断是否含有偶数个数位if len(str_num) % 2 != 0:return Falsestr_num_list = list(str_num)# 分成前半部分和后半部分left_num_list = list(map(int, str_num_list[:len(str_num) // 2]))right_num_list = list(map(int, str_num_list[len(str_num) // 2:]))return sum(left_num_list) == sum(right_num_list) ans = 0
for num in range(1, 100000000):if check_num(num):print(num)ans += 1
print(ans)