Python Code Difference of Two Solutions

Revision en1, by one0one, 2019-09-13 23:13:35

http://codeforces.me/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.me/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?

Tags #python 3

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English one0one 2019-09-13 23:13:35 743 Initial revision (published)