Why two equal Java codes give different results? (test #13)

First code gives wrong answer test #13. In the next code I changed

System.out.print(2*n/k+2*n%k);

and used Math.ceil()

System.out.print((int)Math.ceil(2*(float)n/(float)k));

The code was accepted. What's wrong?

*Edited by author 03.08.2015 07:16*

*Edited by author 03.08.2015 07:17*

*Edited by author 03.08.2015 07:17*

*Edited by author 03.08.2015 07:17*

*Edited by author 03.08.2015 07:18*

*Edited by author 03.08.2015 07:18*

*Edited by author 03.08.2015 07:22*