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.
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner s = new Scanner(System.in);
int n=s.nextInt();
int l=0,x=0;
ArrayList<Integer> al = new ArrayList();
while(x<n){
x = 1 << l;
al.add(x);
}
int[] count = new int[n+1];
count[0]=1;
for(int i=1;i<n+1;i++){
for(int j=0;j<al.size();j++){
if(i>=al.get(j))
count[i]+=count[i-al.get(j)];
}
}
int k=count[n];
System.out.println(k);
}
what is the problem..showing:unsafe operations
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #169: Exploring the number of different ways a number can be expressed as a sum of powers of 2.
You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
what is the problem..showing:unsafe operations