/* package whatever; // don't place package name! */ import java.util.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { int n = 5; for (int i = 0; i < 20; i++){ } } Map a=new HashMap();List a(int b){List c=new ArrayList();int d=b,e=b(b,d),f=(int)(Math.random()*e),g,i;while(b>0){for(g=0;g++<Math.min(d, b);f-=i){i=b(b-g,g);if(f<i)break;}c.add(g);d=g;b-=g;}return c;}int b(int b,int c){if(b<1)return 1;List d=Arrays.asList(b,c);if(a.containsKey(d))return(int)a.get(d);int e,f;for(e=f=0;f++<Math.min(c, b);)e+=b(b-f,f);a.put(d,e);return e;} }
Standard input is empty
[4, 1] [2, 1, 1, 1] [1, 1, 1, 1, 1] [1, 1, 1, 1, 1] [4, 1] [1, 1, 1, 1, 1] [3, 2] [5] [3, 1, 1] [2, 1, 1, 1] [3, 1, 1] [1, 1, 1, 1, 1] [4, 1] [5] [1, 1, 1, 1, 1] [4, 1] [3, 2] [2, 2, 1] [3, 2] [4, 1]