Source code for submission s622

Go to diff to previous submission

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=n+1; x<=2*n; x++) {
  26. if ((x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) {
  27. //cout << "added " << x-n << " for " << n << endl;
  28. pocet++;
  29. }
  30. }
  31.  
  32. printf("%d\n", pocet);
  33. }
  34.  
  35. return 0;
  36. }
  37.  

Diff to submission s587

fl.cpp

--- c5.s587.cteam078.fl.cpp.0.fl.cpp
+++ c5.s622.cteam078.fl.cpp.0.fl.cpp
@@ -23,7 +23,7 @@
 pocet = 0;
 //cout << n << endl;
-        for (int x=0; x<1000000; x++) {
-             if ((x-n > 0) && (x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) {
-//cout << "added " << x << " for " << n << endl;
+        for (int x=n+1; x<=2*n; x++) {
+             if ((x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) {
+//cout << "added " << x-n << " for " << n << endl;
                 pocet++;
              }