fork download
  1. //#pragma GCC optimize("O3", "unroll-loops")
  2. //#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt")
  3.  
  4. #include <bits/stdc++.h>
  5. #define ldb long double
  6. //#define double ldb
  7. #define db double
  8. #define unomap unordered_map
  9. #define unoset unordered_set
  10. #define endl '\n'
  11. #define str string
  12. #define strstr stringstream
  13. #define sz(a) (int)a.size()
  14. #define ll long long
  15. //#define int ll
  16. #define pii pair <int, int>
  17. #define pll pair <ll, ll>
  18. #define Unique(a) a.resize(unique(all(a)) - a.begin())
  19. #define ull unsigned ll
  20. #define fir first
  21. #define sec second
  22. #define idc cin.ignore()
  23. #define lb lower_bound
  24. #define ub upper_bound
  25. #define all(s) s.begin(), s.end()
  26. #define rev reverse
  27. #define gcd __gcd
  28. #define pushb push_back
  29. #define popb pop_back
  30. #define pushf push_front
  31. #define popf pop_front
  32. #define mul2x(a, x) a << x
  33. #define div2x(a, x) a >> x
  34. #define lcm(a, b) (a / __gcd(a, b) * b)
  35. #define log_base(x, base) log(x) / log(base)
  36. #define debug clog << "No errors!"; exit(0);
  37. #define forw(i, a, b) for (int i = a; i <= b; ++i)
  38. #define forw2(i, a, b) for (ll i = a; i <= b; ++i)
  39. #define fors(i, a, b) for (int i = a; i >= b; --i)
  40. #define fors2(i, a, b) for (ll i = a; i >= b; --i)
  41. #define pqueue priority_queue
  42. #define sqrt sqrtl
  43. #define popcount __builtin_popcountll
  44. #define BIT(x, i) (x >> i) & 1
  45. #define MASK(x) (1LL << x)
  46. #define want_digit(x) cout << fixed << setprecision(x);
  47. #define excuting_time 1000.0 * clock() / CLOCKS_PER_SEC
  48. using namespace std;
  49. const int MOD = 1e9 + 7; // 998244353
  50. const int inf = 1e9;
  51. const ll INF = 1e18;
  52. const int N = 1e4;
  53. const int K = 10;
  54.  
  55. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  56. ll random(const ll &L, const ll &R)
  57. {
  58. return uniform_int_distribution<ll> (L, R) (rng);
  59. }
  60.  
  61. int n, k;
  62. ll dp[K + 5][(K - 1) * N + 5];
  63. void solve()
  64. {
  65. cin >> n >> k;
  66. dp[0][0] = 1;
  67. for (int t = 1; t * t < n; ++t)
  68. {
  69. fors (i, k, 1)
  70. {
  71. forw (j, t * t, (k - 1) * n)
  72. dp[i][j] += dp[i - 1][j - t * t];
  73. }
  74. }
  75.  
  76. cout << dp[k][(k - 1) * n] << endl;
  77. }
  78.  
  79. signed main()
  80. {
  81. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  82. srand(time(NULL));
  83. #define name "test"
  84. /*
  85.   if (fopen(name".INP", "r"))
  86.   {
  87.   freopen(name".INP", "r", stdin);
  88.   freopen(name".OUT", "w", stdout);
  89.   }
  90.   */
  91. int numTest = 1;
  92. // cin >> numTest;
  93. while (numTest--)
  94. {
  95. solve();
  96. }
  97. return 0;
  98. }
  99.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
1