import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int arr[]=new int[16];
for(int i=1,q=1;i<16;i++,q*=2){
arr[i]=q;
}
int i=1;
while(true) {
int x=Integer.parseInt(br.readLine());
if(x<0)
break;
int res=0;
for(int j=0;j<arr.length;j++){
if(arr[j]>=x){
res=j-1;
break;
}
}
sb.append("Case ").append(i).append(": ").append(res).append("\n");
i++;
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int arr[]=new int[16];
for(int i=1,q=1;i<16;i++,q*=2){
arr[i]=q;
}
int i=1;
while(true) {
int x=Integer.parseInt(br.readLine());
if(x<0)
break;
int res=0;
for(int j=0;j<arr.length;j++){
if(arr[j]>=x){
res=j-1;
break;
}
}
sb.append("Case ").append(i).append(": ").append(res).append("\n");
i++;
}
System.out.print(sb);
}
}
why aren't you using import java.io.*; statement instead of writing import java.io.BufferedReader,import java.io.IOExecption??Does import java.io.*; statement take much memory??
ReplyDeleteIt is related to compile time
DeleteYou can refer to this link
http://codedmi.com/questions/2359151/difference-between-complete-package-import-and-specified-class-import-java