Source code for submission s808

Go to diff to previous submission

f1.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 (true)
  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.   }*/
  52. pocet++;
  53.  
  54. if (y == x) break;
  55. }
  56. x++;
  57. }
  58. y = 0;
  59. x = 0;
  60. cout << pocet << "\n";
  61. pocet = 0;
  62. }
  63.  
  64. return 0;
  65. }
  66.  

Diff to submission s648

f1.cpp

--- c5.s648.cteam016.fl.cpp.0.f1.cpp
+++ c5.s808.cteam016.fl.cpp.0.f1.cpp
@@ -18,4 +18,5 @@
  {
   cin >> input;
+  if (input.empty()) break;
   n = atoi(input.c_str()+2);
   x = n+1;
@@ -30,11 +31,11 @@
    continue;
   }
-  while (float((x*n))/(x-n) > n+1)
+  while (true)
   {
    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++)
     {
@@ -47,8 +48,9 @@
     if (!nasel)
     {
-     pocet++;
      pouzite.push_back(x);
-    }
-    //if (y == x) break;
+    }*/
+    pocet++;
+    
+    if (y == x) break;
    }
    x++;