企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
硬币算法 ``` #include<stdio.h> # #define AA (1) #define BB (3) #define CC (5) #define SUM (11) # /* ** 求a, b, c三数最小 */ int min(int a, int b, int c ) { int min1 = a; if(b < min1) min1 = b; if(c < min1) min1 = c; return min1; } /* ** 求 d(i) = d(i - v) + 1 */ int my_anser(int sum) { int d[sum+1]; int i = 0, ret = 0; d[0] = 0; for(i = 1; i < sum+1; i++) d[i] = min(d[i - AA] ? d[i - AA] : 0, d[i - BB] ? d[i - BB] : 0, d[i - CC] ? d[i - CC] : 0) + 1; ret = d[i]; return ret; } /* ** */ int main(void) { int sum = SUM; int relt = 0; relt = my_anser(sum); printf("s is %d\n",relt); return 0; } ```