Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

python vs Java ??

$
0
0

Somebody please answer

Here is a very simple spoj question link http://www.spoj.com/problems/JULKA/

my python code is getting WA where as the same logic Java code is getting AC why what am i missing??

PYTHON3 : (This same code gets AC for python 2.7 with necessary adjustments to code syntax but gives WA for Python 3 Why?)

__author__ = "Achut"

for i in range(10):
    a = int(input().strip())
    b = int(input().strip())
    k = int((a+b)/2)
    print(k)
    n = a - k
    print(n)

Java :

import java.util.*;
import java.math.*;

class JULKA {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        for (int t = 0; t < 10; t++) {
            BigInteger A = new BigInteger(in.next());
            BigInteger B = new BigInteger(in.next());
            BigInteger K = (A.add(B)).divide(new BigInteger("2"));
            BigInteger N = A.subtract(K);
            System.out.println(K.toString());
            System.out.println(N.toString());
        }
    }
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>