Source code for submission s587

fl.cpp

  1. #include <cstdio>
  2. #include <vector>
  3. #include <iostream>
  4. #include <string>
  5. #include <algorithm>
  6. #include <cstring>
  7.  
  8. using namespace std;
  9.  
  10. int E(int a, int b) {
  11. if (b==0) {
  12. return a;
  13. } else {
  14. return E(b, a%b);
  15. }
  16. }
  17.  
  18. int main()
  19. {
  20. int n, pocet=0;
  21. while (scanf("1/%d\n", &n) > 0)
  22. {
  23. pocet = 0;
  24. //cout << n << endl;
  25. for (int x=0; x<1000000; x++) {
  26. if ((x-n > 0) && (x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) {
  27. //cout << "added " << x << " for " << n << endl;
  28. pocet++;
  29. }
  30. }
  31.  
  32. printf("%d\n", pocet);
  33. }
  34.  
  35. return 0;
  36. }
  37.