Source code for submission s645

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 (((n*x) % (x-n)) ==0)
  27. {
  28. //cout << "added " << x-n << " for " << n << endl;
  29. ++pocet;
  30. }
  31. }
  32. /*
  33.   for (int i = 1; i <= n; ++i)
  34.   {
  35.   if ((n % i) == 0)
  36.   {
  37.   ++pocet;
  38.   }
  39.   }*/
  40.  
  41. printf("%d\n", pocet);
  42. }
  43.  
  44. return 0;
  45. }
  46.  

Diff to submission s622

fl.cpp

--- c5.s622.cteam078.fl.cpp.0.fl.cpp
+++ c5.s645.cteam078.fl.cpp.0.fl.cpp
@@ -23,10 +23,19 @@
 pocet = 0;
 //cout << n << endl;
-        for (int x=n+1; x<=2*n; x++) {
-             if ((x <= (x*n)/(x-n)) && (E(n*x, x-n) == x-n)) {
+        for (int x=n+1; x<=2*n; ++x) {
+             if (((n*x) % (x-n)) ==0)
+            {
 //cout << "added " << x-n << " for " << n << endl;
-                pocet++;
+                ++pocet;
              }   
         }
+/*
+        for (int i = 1; i <= n; ++i)
+        {
+            if ((n % i) == 0)
+            {
+                ++pocet;
+            }
+        }*/
 
         printf("%d\n", pocet);