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){Scannersc=newScanner(System.in);intq=sc.nextInt();for(inti=0;i<q;i++){BigIntegerbigInt=sc.nextBigInteger();intcheck_l=bigInt.compareTo(BigInteger.valueOf(Long.MAX_VALUE));intcheck_s=bigInt.compareTo(BigInteger.valueOf(Long.MIN_VALUE));if(check_l==1||check_s==-1){System.out.println(bigInt+" can't be fitted anywhere.");}else{longnum=bigInt.longValue();System.out.println(bigInt+" can be fitted in:");if(num<=Byte.MAX_VALUE&&num>=Byte.MIN_VALUE){System.out.println("* byte");}if(num<=Short.MAX_VALUE&&num>=Short.MIN_VALUE){System.out.println("* short");}if(num<=Integer.MAX_VALUE&&num>=Integer.MIN_VALUE){System.out.println("* int");}if(num<=Long.MAX_VALUE&&num>=Long.MIN_VALUE){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 →