Source code for submission s667

two2.cpp

  1. #include <algorithm>
  2. #include <cctype>
  3. #include <cmath>
  4. #include <cstdio>
  5. #include <cstring>
  6. #include <iostream>
  7. #include <list>
  8. #include <map>
  9. #include <queue>
  10. #include <set>
  11. #include <sstream>
  12. #include <stack>
  13. #include <string>
  14. #include <utility>
  15. #include <vector>
  16. using namespace std;
  17.  
  18. #define DEBUG(x) cerr << ">> " << #x << ": " << x << endl;
  19. #define REP(i,a) for (int i =0; i < (a);++i)
  20. #define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
  21.  
  22. char pom;
  23. int n;
  24. unsigned long long x,y;
  25. unsigned long long lft, rght;
  26. int counter = 0;
  27. bool once = false;
  28. int main() {
  29. // while (scanf("%d%d",) != EOF)
  30. while ( cin >> pom >> pom >> n ){
  31. int x = n + 1;
  32. y = x;
  33. counter = 0;
  34. lft= n * ( x + y );
  35. rght = x * y;
  36. while ( true ){
  37. if ( lft == rght ){
  38. once = false;
  39. //cout << "reseni " << x << " " << y;
  40. x = x + 1;
  41. y = x;
  42. lft= n * ( x + y );
  43. rght = x * y;
  44. counter++;
  45. } else if ( lft < rght ){
  46. if ( !once ){
  47. //moc velka x a y
  48. break;
  49. }
  50. x++;
  51. y = x;
  52. lft= n * ( x + y );
  53. rght = x * y;
  54. once = false;
  55. } else {
  56. once=true;
  57. y++;
  58. lft = lft + n;
  59. rght = rght + x;
  60. }
  61. }
  62. cout << counter << endl;
  63.  
  64. }
  65. return 0;
  66. }