提交时间:2022-08-18 10:59:31
运行 ID: 55422
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int n,m,k; int homework[501],now,ans; void DFS(int x,int remain,int cnt) { if(remain < 0) return; if(cnt == m) { ans++; if(ans > Mod) ans -= Mod; return; } for(int i = x;homework[i] <= remain && i <= n;i++) DFS(x,remain - homework[i],cnt + 1); } int main() { scanf("%d%d%d",&n,&m,&k); for(int i = 1,x;i <= n;i++) { scanf("%d",&x); if(x > k) continue; homework[++now] = x; } n = now; sort(homework + 1,homework + 1 + n); DFS(1,k - homework[1],0); printf("%d\n",ans); return 0; }