fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double f(int a, int b, int c) {
  5. return double(double(a)*double(c) + double(b))/double(c);
  6. }
  7.  
  8. void p(int a, int b, int c) {
  9. cout<< a<< " "<< b<< " "<< c;
  10. }
  11.  
  12. int main() {
  13. int a, b, c;
  14. cin>> a>> b>> c;
  15. int d = 0;
  16. if (a == 0) d++;
  17. if (b == 0) d++;
  18. if (c == 0) d++;
  19. if (d == 3) {
  20. cout<< -1;
  21. return 0;
  22. }
  23. if (d == 2) {
  24. cout<< "0 0 "<< a+b+c;
  25. return 0;
  26. }
  27. if (d == 1) {
  28. int x = a, y = b;
  29. if (x == 0) x = c;
  30. if (y == 0) y = c;
  31. if (x < 0 && y < 0) {
  32. cout<< 0<< " "<< min(x, y)<< " "<< max(x, y);
  33. return 0;
  34. }
  35. if (x > y)
  36. cout<< x<< " 0 "<< y;
  37. else
  38. cout<< y<< " 0 "<< x;
  39. return 0;
  40. }
  41. double k[6];
  42. k[0] = f(a, b, c);
  43. k[1] = f(a, c, b);
  44. k[2] = f(b, a, c);
  45. k[3] = f(b, c, a);
  46. k[4] = f(c, a, b);
  47. k[5] = f(c, b, a);
  48. int i = 0;
  49. for (int j = 1; j < 6; j++)
  50. if (k[j] > k[i])
  51. i = j;
  52. switch (i) {
  53. case 0: p(a, b, c); break;
  54. case 1: p(a, c, b); break;
  55. case 2: p(b, a, c); break;
  56. case 3: p(b, c, a); break;
  57. case 4: p(c, a, b); break;
  58. case 5: p(c, b, a); break;
  59. }
  60. return 0;
  61. }
  62.  
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
21855 21855 -470220199