1017 A除以B (20分)
程序员文章站
2022-06-07 14:19:54
...
输入样例:
123456789050987654321 7
输出样例:
17636684150141093474 3
# -*- coding: utf-8 -*-
import re
def big_division(a, b):
q_list, r = [], 0
len_a = len(a)
for i in range(0, len_a):
dividend = 10 * r + eval(a[i])
q_list.append(dividend // eval(b))
r = dividend % eval(b)
if len(q_list) == 1 and q_list[0] == 0:
return q_list[0], r
q = eval(re.sub(r'^[0]{1,100}', '', ''.join(list(map(str, q_list)))))
return q, r
if __name__ == '__main__':
input_list = input().split()
a = input_list[0]
b = input_list[1]
result = big_division(a, b)
print(result[0], result[1])
下一篇: 后台代码中上传文件的大小设置
推荐阅读