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.BigInteger;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);intq=sc.nextInt();BigIntegerinput;for(inti=0;i<q;i++){StringinputString=sc.next();input=newBigInteger(inputString);if(BigInteger.valueOf(input.longValue()).equals(input)){System.out.println(String.format("%d can be fitted in:",input));if(BigInteger.valueOf(input.byteValue()).equals(input)){System.out.println("* byte");}if(BigInteger.valueOf(input.shortValue()).equals(input)){System.out.println("* short");}if(BigInteger.valueOf(input.intValue()).equals(input)){System.out.println("* int");}System.out.println("* long");}else{System.out.println(String.format("%d can't be fitted anywhere.",input));}}sc.close();}}
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 →