import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scanner=new Scanner(System.in); int m=scanner.nextInt(); int n=scanner.nextInt(); System.out.println(sharingApple(m, n)); scanner.close(); } public static int sharingApple(int m,int n) { if(m==1 || n==1) return 1; if(m<n) return sharingApple(m, m); else if(m>n) return sharingApple(m-n, n)+sharingApple(m, n-1); else return 1+sharingApple(m, n-1); } }
时间: 2024-11-05 11:52:40