Python Code Difference of Two Solutions

Правка en1, от one0one, 2019-09-13 23:13:35

http://codeforces.net/contest/1196/submission/60503250 Got wrong answer

q = int(input())
 
for i in range(q):
	piles = [int(i) for i in input().split()]
	piles.sort()
	print(piles[1] + int((piles[2] - (piles[1] - piles[0])) / 2))

http://codeforces.net/contest/1196/submission/60503474 Got accepted

q = int(input())
 
for i in range(q):
	piles = [int(i) for i in input().split()]
	piles.sort()
	print(piles[1] + ((piles[2] - (piles[1] - piles[0])) // 2))

In my opinion, they do the same work but results are not the same. There is a difference between // operator and int() probably. I searched it but could not find anything. Does anyone know it?

Теги #python 3

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский one0one 2019-09-13 23:13:35 743 Initial revision (published)