fork download
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<map>
  4. #include<cstring>
  5. #include<string>
  6. #include<fstream>
  7. #include<unordered_map>
  8. #define all(a) a.begin(), a.end()
  9. #define fr(i, zz, zzz) for (int i = zz; i <= zzz; i++)
  10. #define ll long long
  11. #define pii pair<int, int>
  12. #define frr(i, zz, zzz) for (int i = zz; i >= zzz; i--)
  13. #define full(asdf) memset(asdf, 0, sizeof(asdf))
  14. #define st first
  15. #define nd second
  16. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  17. using namespace std;
  18. int n, m, k, a[300], sto[300], sum = 0;
  19. unordered_map <string, bool> mp;
  20. void res(int pos) {
  21. string s = "";
  22. fr(i, 1, m) {
  23. s += to_string(sto[i]) + ' ';
  24. // cout << sto[i] << " ";
  25. }
  26. if (mp.count(s) == false)
  27. mp[s] = 1;
  28. }
  29. void Try(int i) {
  30. fr(j, 1, k) {
  31. ++sto[j];
  32. sum += j;
  33.  
  34. if (sum == n)
  35. res(i);
  36. else if (sum + 1 < n && i < m)
  37. Try(i+1);
  38. sum -= j;
  39. --sto[j];
  40. }
  41. }
  42. int main () {
  43. IOS
  44. cin >> n >> m >> k;
  45. Try(1);
  46. cout << mp.size();
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty