#include<stdio.h> #include<math.h>
int numbers(int plate_num, int apple_num){ int sum = 0, i = 1, apple_cur = 0; if(apple_num == 1)return 1; if(plate_num == 1)return 1; if(plate_num == 2)return (floor(apple_num/2)); if(apple_num == plate_num)return 1;
if(plate_num >= 3){ i = plate_num; apple_cur = apple_num - i; for(; i > 0; i--){ if(i > apple_cur){ i = apple_cur; } sum += numbers(i, apple_cur); } }
return sum; }
main(){ int plate_num, apple_num, i; int sum = 0; printf("please input the numbers of plate and apple:\n"); scanf("%d%d", &plate_num, &apple_num);
if(plate_num > apple_num){ plate_num = apple_num; }
for(i = plate_num; i > 0; i--){ sum += numbers(i, apple_num); }
printf("there is %d way to array them.\n", sum); printf("k is %d.\n", sum); }