fork download
  1. using System;
  2. using System.Globalization;
  3.  
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. // 1) Read x
  9. string line = Console.ReadLine();
  10. if (line == null)
  11. {
  12. // no input at all – you can choose to print an error or just exit
  13. Console.WriteLine("NO");
  14. return;
  15. }
  16.  
  17. line = line.Trim().Replace(',', '.');
  18. if (!double.TryParse(line, NumberStyles.Any, CultureInfo.InvariantCulture, out double x))
  19. {
  20. // parsing failed — decide on a default
  21. Console.WriteLine("NO");
  22. return;
  23. }
  24.  
  25. // 2) Read expr index
  26. line = Console.ReadLine();
  27. if (line == null || !int.TryParse(line.Trim(), out int expr))
  28. {
  29. Console.WriteLine("NO");
  30. return;
  31. }
  32.  
  33. const double eps = 1e-6;
  34. bool result;
  35.  
  36. switch (expr)
  37. {
  38. case 1:
  39. // 6*x - 10.2 == 4*x - 2.2
  40. result = Math.Abs((6 * x - 10.2) - (4 * x - 2.2)) < eps;
  41. break;
  42. case 2:
  43. // 15 - (3*x - 3) == 5 - 4*x
  44. result = Math.Abs((15 - (3 * x - 3)) - (5 - 4 * x)) < eps;
  45. break;
  46. case 3:
  47. // 2*(x - 0.5) + 1 == 9
  48. result = Math.Abs((2 * (x - 0.5) + 1) - 9) < eps;
  49. break;
  50. default:
  51. // out‐of‐range expr — treat as NO (or handle as error)
  52. result = false;
  53. break;
  54. }
  55.  
  56. Console.WriteLine(result ? "YES" : "NO");
  57. }
  58. }
  59.  
Success #stdin #stdout 0.07s 28488KB
stdin
Standard input is empty
stdout
NO