#44485: python 50 % NA


hansjiang1017@gmail.com (單純想出題所以在拚30%)

學校 : 不指定學校
編號 : 278037
來源 : [111.242.104.233]
最後登入時間 :
2025-04-02 20:25:21
e628. 10494 - If We Were a Child Again -- UVA | From: [111.242.108.104] | 發表日期 : 2024-12-09 17:22

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

 
#44486: Re: python 50 % NA


sam851015@gmail.com (多挖鼻孔有益身心健康)

學校 : 臺中市立惠文高級中學
編號 : 277705
來源 : [123.192.228.253]
最後登入時間 :
2025-03-11 12:39:29
e628. 10494 - If We Were a Child Again -- UVA | From: [123.192.228.253] | 發表日期 : 2024-12-09 19:33

試試看讓你的程式跑這筆測資

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

 

 
#44488: Re: python 50 % NA


hansjiang1017@gmail.com (單純想出題所以在拚30%)

學校 : 不指定學校
編號 : 278037
來源 : [111.242.104.233]
最後登入時間 :
2025-04-02 20:25:21
e628. 10494 - If We Were a Child Again -- UVA | From: [111.242.108.104] | 發表日期 : 2024-12-09 20:46

試試看讓你的程式跑這筆測資

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了

 
ZeroJudge Forum