package hackerrank;

import java.util.Scanner;

/**
 * https://www.hackerrank.com/challenges/lego-blocks
 */
public class LegoBlocks {
    private static int legoBlocks(int n, int m) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int testCases = in.nextInt();
        for (int t = 0; t < testCases; t++) {
            int n = in.nextInt();
            int m = in.nextInt();
            System.out.println(legoBlocks(n, m));
        }
    }
}

@@ -147,19 +147,20 @@
  static 
-int
+long
  legoBlo
@@ -191,32 +191,658 @@
     
-// TODO%0A        return 0
+long total = (long) Math.pow(combinations(m), n);%0A        System.out.println(%22total: %22 + total);%0A        for (int i = 1; i %3C= m - 1; i++) %7B%0A            long substract = (long) Math.pow(combinations(i), n);%0A            System.out.println(%22substract: %22 + substract);%0A            total -= substract;%0A        %7D%0A        // TODO%0A        return total;%0A    %7D%0A%0A    private static long combinations(int width) %7B%0A        if (width %3C 0) %7B%0A            return 0;%0A        %7D%0A        if (width == 0) %7B%0A            return 1;%0A        %7D%0A        long max = 0;%0A        for (int i = 1; i %3C= 4; i++) %7B%0A            max += combinations(width - i);%0A        %7D%0A        return max
 ;%0A  

Update Lego Blocks