fork download
  1. // Mochi Kasato - MKasato
  2. // FB: https://w...content-available-to-author-only...k.com/mochikasato/
  3. // Problem link: (không cần, bài này sao phải chấm:v)
  4. #include <bits/stdc++.h>
  5. #define boostcode ios_base::sync_with_stdio(0); cin.tie(0);
  6. #define openf if (fopen("test.inp", "r")) {freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout);}
  7. #define fi first
  8. #define se second
  9. #define pb(x) push_back(x)
  10.  
  11. using namespace std;
  12. typedef long long ll;
  13. typedef pair<int, int> pii;
  14. #define y1 ymot
  15.  
  16. int x1, y1, x2, y2;
  17.  
  18. int main() {
  19. boostcode;
  20. // openf;
  21.  
  22. cin >> x1 >> y1 >> x2 >> y2;
  23. ll mau = (ll)y1*y2;
  24. ll tu = (ll)x1*y2 + (ll)x2*y1;
  25. ll ucln = __gcd(tu, mau);
  26. tu /= ucln;
  27. mau /= ucln;
  28. cout << tu << ' ' << mau;
  29.  
  30. return 0;
  31. }
  32. /* TESTS:
  33. Test 1:
  34. 3 6
  35. -->
  36. 67
  37. Test 2:
  38.  
  39. -->
  40.  
  41. Test 3:
  42.  
  43. -->
  44.  
  45. Test 4:
  46.  
  47. -->
  48.  
  49. */
  50.  
Success #stdin #stdout 0.01s 5288KB
stdin
7 10 1 6
stdout
13 15