Source code for submission s905

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. n =1;
  17. while (cin)
  18. {
  19. cin >> input;
  20. if (input.empty()) break;
  21. n = atoi(input.c_str()+2);
  22. //n++;
  23. x = n+1;
  24. if (n == 0)
  25. {
  26. cout << 0 << "\n";
  27. continue;
  28. }
  29. if (n == 1)
  30. {
  31. cout << 1 << "\n";
  32. continue;
  33. }/*
  34.   while (float((x*n)/(x-n)) > n+1)
  35.   {
  36.   if((x*n)%(x-n)==0)
  37.   {
  38.   y = x*n/(x-n);
  39.   //if (y < x) break;
  40.   nasel = false;
  41.   for (vector<unsigned long>::iterator i = pouzite.begin(); i != pouzite.end(); i++)
  42.   {
  43.   if ((*i) == y)
  44.   {
  45.   nasel = true;
  46.   break;
  47.   }
  48.   }
  49.   if (!nasel)
  50.   {
  51.   pouzite.push_back(x);
  52.   pocet++;
  53.   }
  54.   //pocet++;
  55.  
  56.   //if (y == x) break;
  57.   }
  58.   x++;
  59.   }
  60.   pouzite.clear();
  61.   while (true)
  62.   {
  63.   if((x*n)%(x-n)==0)
  64.   {
  65.   y = x*n/(x-n);
  66.   if (y < x) break;
  67.  
  68.   pocet++;
  69.  
  70.   if (y == x) break;
  71.   }
  72.   x++;
  73.   }
  74. /*/
  75. //int x1=-1;
  76. //cout<<"Number "<<n<<endl;
  77.  
  78. while (x <= n*2)
  79. {
  80. if((x*n)%(x-n)==0)
  81. {
  82.  
  83. //Spocitat y
  84. y = x*n/(x-n);
  85.  
  86. //if (y < x) break;
  87.  
  88. pocet++;
  89. //cout<<" "<<x<<"|"<<y<<endl;
  90. //if (y == x) break;
  91. //zjistit, jestli sme zase na zacatku
  92. /*if(y==x1)
  93.   break;
  94.   //Zapamatovat si prvni x
  95.   if(x1==-1)
  96.   x1=x;*/
  97. }
  98. x++;
  99. }
  100.  
  101. /*while (x < n*(n+1))
  102.   {
  103.   if (x%n == 0) pocet++;
  104.   x++;
  105.   }*/
  106. y = 0;
  107. x = 0;
  108. cout << pocet << "\n";
  109. pocet = 0;
  110. //
  111. }
  112. return 0;
  113. }
  114.  

Diff to submission s834

fl.cpp

--- c5.s834.cteam016.fl.cpp.0.fl.cpp
+++ c5.s905.cteam016.fl.cpp.0.fl.cpp
@@ -12,7 +12,7 @@
  n = x = y = pocet = 0;
  string input;
- vector<unsigned long> pouzite;
+ //vector<unsigned long> pouzite;
  bool nasel = false;
-
+ n =1;
  while (cin)
  {
@@ -20,4 +20,5 @@
   if (input.empty()) break;
   n = atoi(input.c_str()+2);
+  //n++;
   x = n+1;
   if (n == 0)
@@ -56,6 +57,6 @@
    }
    x++;
-  }/*/
-
+  }
+  pouzite.clear();
   while (true)
   {
@@ -71,12 +72,42 @@
    x++;
   }
-//*/
+/*/
+  //int x1=-1;
+  //cout<<"Number "<<n<<endl;
+
+  while (x <= n*2)
+  {
+   if((x*n)%(x-n)==0)
+   {
+
+    //Spocitat y
+    y = x*n/(x-n);
+
+    //if (y < x) break;
+    
+    pocet++;
+    //cout<<"  "<<x<<"|"<<y<<endl;
+    //if (y == x) break;
+    //zjistit, jestli sme zase na zacatku
+    /*if(y==x1)
+      break;
+    //Zapamatovat si prvni x
+    if(x1==-1)
+      x1=x;*/
+   }
+   x++;
+  }
+
+  /*while (x < n*(n+1))
+  {
+   if (x%n == 0) pocet++;
+   x++;
+  }*/
   y = 0;
   x = 0;
   cout << pocet << "\n";
   pocet = 0;
-  pouzite.clear();
+  //
  }
- cout << "\n";
  return 0;
 }