fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(NULL);
  10.  
  11. long long x0, y0, type;
  12. if (cin >> x0 >> y0 >> type) {
  13. if (type < 1 || type > 4) {
  14. cout << "INVALID TYPE\n";
  15. return 0;
  16. }
  17.  
  18. double p = 0.0;
  19. double x = (double)x0;
  20. double y = (double)y0;
  21.  
  22. if (type == 1) {
  23. p = sqrt(x * x + y * y);
  24. } else if (type == 2) {
  25. p = abs(x) + abs(y);
  26. } else if (type == 3) {
  27. p = (x * x + y * y) / (abs(x - y) + 1.0);
  28. } else if (type == 4) {
  29. p = cbrt(abs(x * x * x - y * y * y));
  30. }
  31.  
  32. cout << fixed << setprecision(2) << p << "\n";
  33.  
  34. if (x0 == 0 && y0 == 0) {
  35. cout << "BASE DEFENSE\n";
  36. } else if (p < 100.0) {
  37. cout << "SAFE\n";
  38. } else if (p <= 1000000.0) {
  39. cout << "WARNING\n";
  40. } else {
  41. cout << "DANGER\n";
  42. }
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty