Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. std::map<std::pair<int, int>, int> cache;
  4. int junior5(int n, int k) {
  5. if(n < k) {
  6. return 0;
  7. }
  8. if(k == 1 || k == n) {
  9. return 1;
  10. }
  11. if(cache.find(std::pair<int, int>(n, k)) != cache.end()) {
  12. return cache[std::pair<int, int>(n, k)];
  13. }
  14. cache[std::pair<int, int>(n, k)] = junior5(n - 1, k - 1) + junior5(n - k, k);
  15. return cache[std::pair<int, int>(n, k)];
  16. }
  17.  
  18. int main() {
  19. int a, b;
  20. std::cin >> a >> b;
  21. std::cout << junior5(a, b) << std::endl;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement