fork download
  1. using System;
  2. class Program
  3. {
  4. static long max = -9223372036854775733L;
  5. static long tempMax = max;
  6. static long[] A;
  7. static int N, K;
  8. static void Main(string[] args)
  9. {
  10. Input();
  11. Logic();
  12. Display();
  13. // Console.ReadLine();
  14. }
  15. static void Input()
  16. {
  17. string[] x;
  18. x = Console.ReadLine().Split(' ');
  19. N = Convert.ToInt32(x[0]);
  20. K = Convert.ToInt32(x[1]);
  21. x = Console.ReadLine().Split(' ');
  22. A = new long[N];
  23. for (int n = 0; n < N; n++)
  24. {
  25. A[n] = Convert.ToInt64(x[n]);
  26. if (A[n] > max)
  27. {
  28. max = A[n];
  29. }
  30. }
  31. }
  32. static void Logic()
  33. {
  34. if ((K % 2 == 0) && K != 0)
  35. {
  36. Calculate();
  37. Calculate();
  38. }
  39. if ((K % 2 == 1) && K != 0)
  40. {
  41. Calculate();
  42. }
  43. }
  44. static void Calculate()
  45. {
  46. tempMax = max;
  47. for (int n = 0; n < N; n++)
  48. {
  49. A[n] = max - A[n];
  50. if (A[n] > max)
  51. {
  52. tempMax = A[n];
  53. }
  54. }
  55. max = tempMax;
  56. }
  57. static void Display()
  58. {
  59. for (int n = 0; n < N; n++)
  60. {
  61. Console.Write(A[n] + " ");
  62. }
  63. Console.WriteLine();
  64. }
  65. }
Success #stdin #stdout 0.04s 33968KB
stdin
2 2
1 2
stdout
1 2