Anophoo

Final_2013_3_attempt2

Jul 8th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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) {
  22. count++;
  23. return;
  24. }
  25. recurs(n - 1, count, ints);
  26. foreach (int k in ints) {
  27. if (n % k == 0) {
  28. recurs(n / k, count, ints);
  29. }
  30. }
  31. }
  32.  
  33. int pathCount(int n, int a[2]) {
  34. Set<int> ints;
  35. for (int i = 0; i < 2; i++) {
  36. ints.add(a[i]);
  37. }
  38. int count = 0;
  39. recurs(n, count, ints);
  40. return count;
  41. }
  42.  
  43. int main() {
  44. int n = 6;
  45. int a[2] = {2, 3};
  46. int p = pathCount(n, a);
  47. cout << p << endl;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment