50%NA
while True:
try:
a,o,b = input().split()
a = int(a)
b = int(b)
print(a%b if o == "%" else int(a/b))
except EOFError:
break
試試看讓你的程式跑這筆測資
99999999999999999 / 100000000000000000
|
我電腦上用的是 python 3.12,但依然會輸出不理想的結果,zerojudge 的 python 3.6 當然就......
這篇討論應該能解答你的問題
What is the difference between a//b and int(a/b)? | Stack Overflow
大意就是雖然大數運算對 python 來說是水題,但也是有極限,不是無敵的,在極端情況下(數字大到靠北or硬體設備性能限制or比較神奇的數字),int(num)
未必總是相當於非負浮點數向下取整的值
請愛用雙斜槓 //
另一個踩一樣坑的人: Are there any differences between applying floor division and int() after dividing? | Stack Overflow
試試看讓你的程式跑這筆測資
99999999999999999 / 100000000000000000
我電腦上用的是 python 3.12,但依然會輸出不理想的結果,zerojudge 的 python 3.6 當然就......
這篇討論應該能解答你的問題
What is the difference between a//b and int(a/b)? | Stack Overflow
大意就是雖然大數運算對 python 來說是水題,但也是有極限,不是無敵的,在極端情況下(數字大到靠北or硬體設備性能限制or比較神奇的數字),
int(num)
未必總是相當於非負浮點數向下取整的值請愛用雙斜槓
//
另一個踩一樣坑的人: Are there any differences between applying floor division and int() after dividing? | Stack Overflow
謝謝您,ac了