You are viewing a single comment's thread. Return to all comments →
import java.util.; import java.math.;
class Solution { public static void main(String[] argh) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); // Consume newline
for (int i = 0; i < t; i++) { String value = sc.nextLine(); try { BigInteger x = new BigInteger(value); System.out.println(x + " can be fitted in:"); if (x.compareTo(BigInteger.valueOf(Byte.MIN_VALUE)) >= 0 && x.compareTo(BigInteger.valueOf(Byte.MAX_VALUE)) <= 0) System.out.println("* byte"); if (x.compareTo(BigInteger.valueOf(Short.MIN_VALUE)) >= 0 && x.compareTo(BigInteger.valueOf(Short.MAX_VALUE)) <= 0) System.out.println("* short"); if (x.compareTo(BigInteger.valueOf(Integer.MIN_VALUE)) >= 0 && x.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) <= 0) System.out.println("* int"); if (x.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) >= 0 && x.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) <= 0) System.out.println("* long"); } catch (Exception e) { System.out.println(value + " can't be fitted anywhere."); } } sc.close(); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Datatypes
You are viewing a single comment's thread. Return to all comments →
import java.util.; import java.math.;
class Solution { public static void main(String[] argh) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); // Consume newline
}