We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;importjava.math.*;publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannersc=newScanner(System.in);intcount=Integer.parseInt(sc.nextLine());for(inti=0;i<count;i++){StringstrNum=sc.nextLine();BigIntegerbigNum=newBigInteger(strNum);if((bigNum.compareTo(BigInteger.ZERO)>0&&bigNum.compareTo(BigInteger.valueOf(Long.MAX_VALUE))>0)||(bigNum.compareTo(BigInteger.ZERO)<0&&bigNum.compareTo(BigInteger.valueOf(Long.MIN_VALUE))<0)){System.out.println(bigNum+" can't be fitted anywhere.");}elseSystem.out.println(bigNum+" can be fitted in:");if(bigNum.compareTo(BigInteger.valueOf(Byte.MAX_VALUE))<=0&&bigNum.compareTo(BigInteger.valueOf(Byte.MIN_VALUE))>=0){System.out.println("* byte");}if(bigNum.compareTo(BigInteger.valueOf(Short.MAX_VALUE))<=0&&bigNum.compareTo(BigInteger.valueOf(Short.MIN_VALUE))>=0){System.out.println("* short");}if(bigNum.compareTo(BigInteger.valueOf(Integer.MAX_VALUE))<=0&&bigNum.compareTo(BigInteger.valueOf(Integer.MIN_VALUE))>=0){System.out.println("* int");}if(bigNum.compareTo(BigInteger.valueOf(Long.MAX_VALUE))<=0&&bigNum.compareTo(BigInteger.valueOf(Long.MIN_VALUE))>=0){System.out.println("* long");}}}}
Cookie support is required to access HackerRank
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 →
This is the solution for all the testcases