ç¨vbåï¼ç¨ä¸å¼ ä¸å
票æ¢1åã2åå5åç硬å¸ï¼æ¯ç§è³å°ä¸æï¼ é®æåªå ç§æ¢æ³ï¼åå æï¼
#include<iostream>using namespace std;#define LEN 3 int a[] = {1, 2, 5};int remain(int i){ int total = 0; for(int j=LEN-1;j>i;j--) total += a[j]; return total;}long dfs(int total, int i){ if(i>=3){ if(total==0) return 1; return 0; } long res = 0; for(int num=1;total-a[i]*num>=remain(i);++num){ res += dfs(total-num*a[i], i+1); } return res;}int main(){ printf("%ld\n", dfs(100, 0)); }
çæ¡æ¯461ç§ã
温馨提示:内容为网友见解,仅供参考