Anophoo

Final_2013_3

Jul 8th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <cstdio>
  5. #include <algorithm>
  6. #include <string>
  7. #include "set.h"
  8. #include "console.h"
  9. #include "vector.h"
  10. #include "simpio.h"
  11. #include "Lexicon.h"
  12. #include "ResizableArray.h"
  13. #include "MyVector.h"
  14. #include "bst.h"
  15. #include "MyMatrix.h"
  16. #include "random.h"
  17.  
  18. using namespace std;
  19.  
  20. void recurs(int n, int &count, Set<int> ints) {
  21. if (n == 1) count++;
  22. recurs(n - 1, count, ints);
  23. foreach (int k in ints) {
  24. if (n % k == 0) {
  25. recurs(n / k, count, ints);
  26. }
  27. }
  28. }
  29.  
  30. int pathCount(int n, int a[2]) {
  31. Set<int> ints;
  32. for (int i = 0; i < 2; i++) {
  33. ints.add(a[i]);
  34. }
  35. int count = 0;
  36. recurs(n, count, ints);
  37. return count;
  38. }
  39.  
  40. int main() {
  41. int n = 3;
  42. int a[2] = {2, 3};
  43. int p = pathCount(n, a);
  44. cout << p << endl;
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment