Source code for submission s823

Go to diff to previous submission

fl.cpp

  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <cstdio>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. int main ()
  10. {
  11. unsigned long n, x, y, pocet;
  12. n = x = y = pocet = 0;
  13. string input;
  14. vector<unsigned long> pouzite;
  15. bool nasel = false;
  16.  
  17. while (cin)
  18. {
  19. cin >> input;
  20. if (input.empty()) break;
  21. n = atoi(input.c_str()+2);
  22. x = n+1;
  23. if (n == 0)
  24. {
  25. cout << 0 << "\n";
  26. continue;
  27. }
  28. if (n == 1)
  29. {
  30. cout << 1 << "\n";
  31. continue;
  32. }
  33. while (float((x*n)%(x-n)) < n+1)
  34. {
  35. if((x*n)%(x-n)==0)
  36. {
  37. y = x*n/(x-n);
  38. //if (y < x) break;
  39. nasel = false;
  40. for (vector<unsigned long>::iterator i = pouzite.begin(); i != pouzite.end(); i++)
  41. {
  42. if ((*i) == y)
  43. {
  44. nasel = true;
  45. break;
  46. }
  47. }
  48. if (!nasel)
  49. {
  50. pouzite.push_back(x);
  51. pocet++;
  52. }
  53. //pocet++;
  54.  
  55. //if (y == x) break;
  56. }
  57. x++;
  58. }
  59. y = 0;
  60. x = 0;
  61. cout << pocet << "\n";
  62. pocet = 0;
  63. pouzite.clear();
  64. }
  65. return 0;
  66. }
  67.  

Diff to submission s815

fl.cpp

--- c5.s815.cteam016.fl.cpp.0.fl.cpp
+++ c5.s823.cteam016.fl.cpp.0.fl.cpp
@@ -13,4 +13,5 @@
  string input;
  vector<unsigned long> pouzite;
+ bool nasel = false;
 
  while (cin)
@@ -30,11 +31,11 @@
    continue;
   }
-  while (true)
+  while (float((x*n)%(x-n)) < n+1)
   {
    if((x*n)%(x-n)==0)
    {
     y = x*n/(x-n);
-    if (y < x) break;
-    /*nasel = false;
+    //if (y < x) break;
+    nasel = false;
     for (vector<unsigned long>::iterator i = pouzite.begin(); i != pouzite.end(); i++)
     {
@@ -48,8 +49,9 @@
     {
      pouzite.push_back(x);
-    }*/
-    pocet++;
+     pocet++;
+    }
+    //pocet++;
     
-    if (y == x) break;
+    //if (y == x) break;
    }
    x++;
@@ -59,4 +61,5 @@
   cout << pocet << "\n";
   pocet = 0;
+  pouzite.clear();
  }
  return 0;