Source code for submission s834

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.  
  60. while (true)
  61. {
  62. if((x*n)%(x-n)==0)
  63. {
  64. y = x*n/(x-n);
  65. if (y < x) break;
  66.  
  67. pocet++;
  68.  
  69. if (y == x) break;
  70. }
  71. x++;
  72. }
  73. //*/
  74. y = 0;
  75. x = 0;
  76. cout << pocet << "\n";
  77. pocet = 0;
  78. pouzite.clear();
  79. }
  80. cout << "\n";
  81. return 0;
  82. }
  83.  

Diff to submission s830

fl.cpp

--- c5.s830.cteam016.fl.cpp.0.fl.cpp
+++ c5.s834.cteam016.fl.cpp.0.fl.cpp
@@ -30,5 +30,5 @@
    cout << 1 << "\n";
    continue;
-  }
+  }/*
   while (float((x*n)/(x-n)) > n+1)
   {
@@ -56,5 +56,20 @@
    }
    x++;
+  }/*/
+
+  while (true)
+  {
+   if((x*n)%(x-n)==0)
+   {
+    y = x*n/(x-n);
+    if (y < x) break;
+    
+    pocet++;
+    
+    if (y == x) break;
+   }
+   x++;
   }
+//*/
   y = 0;
   x = 0;