-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
45 lines (41 loc) · 1.79 KB
/
Solution.java
File metadata and controls
45 lines (41 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=1;i<=t;i++)
{
long n=sc.nextLong();
if(((n>=-128)&&(n<=127))&&((n>=-32768)&&(n<=32767))&&((n>=(int)(Math.pow(-2,31))&&(n<=((int)Math.pow(2,31)-1))))&&((n>=(long)(Math.pow(-2,127))&&(n<=(long)(Math.pow(2,127)-1)))))
{
System.out.println(n+" can be fitted in:");
System.out.println("* byte");
System.out.println("* short");
System.out.println("* int");
System.out.println("* long");
}
else if(((n>=-32768)&&(n<=32767))&&((n>=(int)(Math.pow(-2,31))&&(n<=((int)Math.pow(2,31)-1))))&&((n>=(long)(Math.pow(-2,127))&&(n<=(long)(Math.pow(2,127)-1)))))
{
System.out.println(n+" can be fitted in:");
System.out.println("* short");
System.out.println("* int");
System.out.println("* long");
}
else if(((n>=(int)(Math.pow(-2,31))&&(n<=((int)Math.pow(2,31)-1))))&&((n>=(long)(Math.pow(-2,127))&&(n<=(long)(Math.pow(2,127)-1)))))
{
System.out.println(n+" can be fitted in:");
System.out.println("* int");
System.out.println("* long");
}
else if(((n>=(long)(Math.pow(-2,127))&&(n<=(long)(Math.pow(2,127)-1)))))
{
System.out.println(n+" can be fitted in:");
System.out.println("* long");
}
else
{
System.out.println(n+" can't be fitted anywhere");
}
}
}
}