Advertisement
Guest User

Untitled

a guest
Mar 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Fraction {
  6. private:
  7. long long x,y;
  8.  
  9. int gcd(int a, int b) {
  10. while (a != 0 && b != 0){
  11. if (a > b) a = a % b;
  12. else b = b % a;
  13. }
  14. return a + b;
  15. }
  16.  
  17. void normalize() {
  18. long long nod = gcd (x,y);
  19. if (x < 0 && y < 0) {x = x * -1;y = y * -1;}
  20. if (x > 0 && y < 0) {x = x * -1;y = y * -1;}
  21. x = x / nod;
  22. y = y / nod;
  23. }
  24.  
  25. public:
  26.  
  27. Fraction (long long x = 0, long long y = 1) {
  28. this->x = x;
  29. this->y = y;
  30. }
  31.  
  32. Fraction operator + (const Fraction &s) {
  33. long long a,b;
  34. b = this->y * s.y;
  35. a = this->x * s.y + s.x * this->y;
  36. return Fraction(a,b);
  37. }
  38.  
  39. Fraction operator - (const Fraction &s) {
  40. long long a,b;
  41. b = this->y * s.y;
  42. a = this->x * s.y - s.x * this->y;
  43. return Fraction(a,b);
  44. }
  45.  
  46. Fraction operator * (const Fraction &s) {
  47. long long a,b;
  48. b = this->y * s.y;
  49. a = this->x * s.x;
  50. return Fraction(a,b);
  51. }
  52.  
  53. Fraction operator / (const Fraction &s) {
  54. long long a,b;
  55. b = this->y * s.x;
  56. a = this->x * s.y;
  57. return Fraction(a,b);
  58. }
  59.  
  60. Fraction operator + (long &s) {
  61. long long a,b;
  62. b = this->y;
  63. a = this->x + s * this->y;
  64. return Fraction(a,b);
  65. }
  66.  
  67. Fraction operator -(){
  68. long long a,b;
  69. b = this->y;
  70. a = this->x * -1;
  71. return Fraction(a,b);
  72. }
  73.  
  74.  
  75. bool operator == (const Fraction &s) {
  76. bool ans;
  77. long long a,b;
  78. a = this->x * abs(s.y);
  79. b = abs(this->y) * s.x;
  80. if (this->y < 0) a = a * -1;
  81. if (s.y < 0) b = b * -1;
  82. if (a == b) ans = true;
  83. else ans = false;
  84. return ans;
  85. }
  86.  
  87. bool operator > (const Fraction &s) {
  88. bool ans;
  89. long long a,b;
  90. a = this->x * abs(s.y);
  91. b = abs(this->y) * s.x;
  92. if (this->y < 0) a = a * -1;
  93. if (s.y < 0) b = b * -1;
  94. if (a > b) ans = true;
  95. else ans = false;
  96. return ans;
  97. }
  98.  
  99. bool operator < (const Fraction &s) {
  100. bool ans;
  101. long long a,b;
  102. a = this->x * abs(s.y);
  103. b = abs(this->y) * s.x;
  104. if (this->y < 0) a = a * -1;
  105. if (s.y < 0) b = b * -1;
  106. if (a < b) ans = true;
  107. else ans = false;
  108. return ans;
  109. }
  110.  
  111. friend bool operator < (double d, Fraction &s) {
  112. bool ans;
  113. double a,c;
  114. a = s.x;
  115. c = s.y;
  116. a = a/c;
  117. if (d < a) ans = true;
  118. else ans = false;
  119. return ans;
  120. }
  121.  
  122. friend istream & operator >> (istream & input, Fraction &s){
  123. char z;
  124. input >> s.x >> z >> s.y;
  125. }
  126.  
  127. friend ostream & operator << (ostream & output, Fraction &s){
  128. output << s.x << "/" << s.y;
  129. }
  130.  
  131.  
  132. void show() {
  133. cout << x << "/" << y;
  134. }
  135.  
  136. void read() {
  137. char z;
  138. cin >> x;
  139. cin >> z;
  140. cin >> y;
  141. }
  142. };
  143.  
  144.  
  145. int main() {
  146. Fraction a;
  147. double d;
  148.  
  149. cin >> d;
  150. cin >> a;
  151.  
  152. if (d < a) cout << "YES";
  153. else cout << "NO";
  154.  
  155.  
  156. return 0;
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement