fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define debug(x) cerr << #x << " = " << x << endl;
  4. #define int long long
  5. tuple<int,double,double> ghpt(double a, double b, double c, double a1, double b1, double c1){
  6. // value.first = 0 or 1 or 2 lan luot tuong ung vo nghiem, 1 nghiem, vo so nghiem
  7. double x, y;
  8. if(a == 0){
  9. y = c / b;
  10. if(a1 == 0){
  11. if(abs(y - c1 / b1) < 1e-6) return make_tuple(2, 0, 0);
  12. return make_tuple(0, 0, 0);
  13. }
  14. x = (c1 - b1 * y) / a1;
  15. return make_tuple(1, x, y);
  16. }
  17. if(a1 == 0){
  18. y = c1 / b1;
  19. x = (c - b * y) / a;
  20. return make_tuple(1, x, y);
  21. }
  22. double u = a1 * b - a * b1;
  23. double v = a1 * c - a * c1;
  24. if(u == 0){
  25. if(v == 0) return make_tuple(2, 0, 0);
  26. return make_tuple(0, 0, 0);
  27. }
  28. y = v / u;
  29. x = (c - b * y) / a;
  30. return make_tuple(1, x, y);
  31. }
  32. signed main(){
  33. FILE *pFile = fopen("input.txt", "r");
  34. if(pFile != nullptr) freopen("input.txt", "r", stdin);
  35. ios_base::sync_with_stdio(false);cin.tie(nullptr);
  36. double a, b, c, a1, b1, c1;
  37. cin >> a >> b >> c >> a1 >> b1 >> c1;
  38. int u;
  39. double x, y;
  40. tie(u, x, y) = ghpt(a, b, c, a1, b1, c1);
  41. if(u == 0) cout << "VONGHIEM";
  42. else if(u == 2) cout << "VOSONGHIEM";
  43. else{
  44. cout << fixed << setprecision(2);
  45. cout << x << " " << y;
  46. }
  47. }
Success #stdin #stdout 0.01s 5584KB
stdin
Standard input is empty
stdout
VOSONGHIEM