提交时间:2022-07-20 11:51:51

运行 ID: 52751

#include <bits/stdc++.h> #define ll long long #define mod int(1e9+7) using namespace std; int n, k, m, cnt; int a[400]; ll ans; ll pw(ll a, int b) { ll tmp = a; b -= 1; while(b) { if(b&1) a = a*tmp%mod; tmp = tmp*tmp%mod; b >>= 1; } return a; } void dfs(int lst, int l, int num) { if((num==0&&lst!=0) || (num!=0&&lst==0)) return; if(num==0 && lst==0) { for(int i=1; i<=cnt; i++) ans = (ans+pw(a[i], m))%mod; } for(int i=l+1; i<=lst; i++) { a[++cnt] = i; dfs(lst-i, i, num-1); cnt--; } } int main() { scanf("%d%d%d", &n, &k, &m); dfs(n, 0, k); printf("%lld\n", ans%mod); return 0; }