← Back to Forum
CCC '15 J5 - π-day
//Ivan Li, Markville secondary school
import java.io.*;
import java.util.*;
public class ccc15j5{
public static int memo[][] = new int[251][251];
public static int solve(int n, int k){
if(k<0||n<1) return 0;
if(k==0) return 1;
if(memo[n][k]!=0) return memo[n][k];
return memo[n][k]=solve(n-1, k)+solve(n, k-n);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int k =sc.nextInt();
int n = sc.nextInt();
System.out.println(solve(n, k-n));
}
}
By IvanLi on 11/2/2025
0
Comments
Solution added to GitHub on 11/12/2025, as well as all of Ivan Li's solutions below
By msu7 on 11/13/2025