关于有符号数数据范围问题的参考资料:

https://www.jianshu.com/p/0ad27ad30a43

https://wenku.baidu.com/view/65bb27c9360cba1aa811dae2.html

溢出处理方法:

https://www.docin.com/p-273724627.html

题目:


解题思路:


eval直接计算算数表达式的值

获得溢出后的数字:

ac代码:


我的第一个py代码( ´▽`)


x = 0x100000000
# x=2^32
a = 0x7FFFFFFF
# a=2^31-1
b = -(a+1)
# b=-(2^31)
t = input()
while t > 0:
    s = input()
    num = (eval("s"))
    while num > a:
     num -= x
    while num < b:
     num += x
    print(num)
    t = t-1