Source code for submission s520

Go to diff to previous submission

f1.cpp

  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <cstdio>
  5.  
  6. using namespace std;
  7.  
  8. int main ()
  9. {
  10. int n, x, y, pocet;
  11. n = x = y = pocet = 0;
  12. string input;
  13.  
  14. while (cin)
  15. {
  16. cin >> input;
  17. n = atoi(input.c_str()+2);
  18. x = n+1;
  19. if (n == 1)
  20. {
  21. cout << 1 << "\n";
  22. continue;
  23. }
  24. while (true)
  25. {
  26. if((x*n)%(x-n)==0)
  27. {
  28. y = x*n/(x-n);
  29. if (y < x) break;
  30. pocet++;
  31. if (y == x) break;
  32. }
  33. x++;
  34. }
  35. y = 0;
  36. x = 0;
  37. cout << pocet << "\n";
  38. pocet = 0;
  39. }
  40.  
  41. return 0;
  42. }
  43.  

Diff to submission s506

f1.cpp

--- c5.s506.cteam016.fl.cpp.0.f1.cpp
+++ c5.s520.cteam016.fl.cpp.0.f1.cpp
@@ -29,4 +29,5 @@
     if (y < x) break;
     pocet++;
+    if (y == x) break;
    }
    x++;