import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scanner=new Scanner(System.in); while(scanner.hasNext()) { int n=scanner.nextInt(); if(n==0) { break; } List<Integer> ints=new ArrayList<>(); while(n>0) { int temp=n%2; n/=2; ints.add(temp); } int sum=0; for(int i=0;i<ints.size();i++) { if(ints.get(i)!=0) { break; } sum++; } System.out.println((int)Math.pow(2, sum)); } } } /* Main.c:3:1: error: unknown type name 'import' import java.util.ArrayList; ^ Main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token import java.util.ArrayList; ^ Main.c:4:1: error: unknown type name 'import' import java.util.Collections; ^ Main.c:4:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token import java.util.Collections; ^ Main.c:5:1: error: unknown type name 'import' import java.util.List; ^ Main.c:5:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token import java.util.List; ^ Main.c:6:1: error: unknown type name 'import' import java.util.Scanner; ^ Main.c:6:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token import java.util.Scanner; ^ Main.c:8:1: error: unknown type name 'public' public class Main { ^ Main.c:8:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main' public class Main { ^ */ |
Double click to view unformatted code.