Source code for submission s917

Go to diff to previous submission

fl.cpp

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

Diff to submission s905

fl.cpp

--- c5.s905.cteam016.fl.cpp.0.fl.cpp
+++ c5.s917.cteam016.fl.cpp.0.fl.cpp
@@ -1,4 +1,5 @@
 #include <iostream>
 #include <string>
+#include <cstring>
 #include <cstdlib>
 #include <cstdio>
@@ -106,5 +107,5 @@
   y = 0;
   x = 0;
-  cout << pocet << "\n";
+  cout << pocet << endl;
   pocet = 0;
   //