/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package Final; import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.math.BigInteger; import java.util.HashMap; import java.util.Scanner; /** * * @author alexhuleatt */ public class Coins { static int[] cubes = new int[]{1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2197, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261}; static BigInteger[][] vals; public static void main(String[] args) throws FileNotFoundException { Scanner sc = new Scanner(new File("bodensee.in")); PrintWriter out = new PrintWriter("bodensee.out"); vals = new BigInteger[10001][21]; while (sc.hasNext()) out.println(count(sc.nextInt(), 20)); out.close(); } public static BigInteger count(int n, int max) { if (vals[n][max] != null) return vals[n][max]; if (n == 0) return BigInteger.ONE; if (BigInteger.valueOf(n).compareTo(BigInteger.valueOf(8)) == -1) { return BigInteger.ONE; } BigInteger count = BigInteger.ONE; for (int i = 1; i <= max; i++) { if (cubes[i] <= n) { count = count.add(count(n - cubes[i], i)); } } return vals[n][max] = count; } }