#include <iostream>
#include <vector>
#include<string>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#include<unordered_map>
int res = 0;
vector<vector<int>> final_res;
void DFS(vector<int> &path,int sum,int n,int k,int start) {
if (sum == n) {
res++;
final_res.push_back(path);
return;
}
if (sum > n) return;
//drill down
for (int i = start; i <= n; i++) {
if (i%k == 0) continue;
path.push_back(i);
DFS(path,sum+i,n,k,i);
path.pop_back();
}
return;
}
int main() {
vector<int> path;
DFS(path,0,9,3,1);
cout << res << endl;
return 0;
}
网友评论