private static void Main() { var output = new StringBuilder(); int remainingTestCases = int.Parse(Console.ReadLine()); while (remainingTestCases-- > 0) { int[] line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); int arrayLength = line[0]; var solver = new HORRIBLE(arrayLength); int commandCount = line[1]; for (int c = 0; c < commandCount; ++c) { int[] command = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); if (command[0] == 0) { solver.Update( updateStartIndex: command[1] - 1, updateEndIndex: command[2] - 1, delta: command[3]); } else { output.Append(solver.Query( queryStartIndex: command[1] - 1, queryEndIndex: command[2] - 1)); output.AppendLine(); } } } Console.Write(output); }
private static void Main() { int remainingTestCases = int.Parse(Console.ReadLine()); var output = new StringBuilder(); while (remainingTestCases-- > 0) { int[] line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); int arrayLength = line[0]; int commandCount = line[1]; var solver = new HORRIBLE(arrayLength); for (int c = 0; c < commandCount; ++c) { int[] command = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); if (command[0] == 0) { solver.Update( updateStartIndex: command[1] - 1, updateEndIndex: command[2] - 1, delta: command[3]); } else // command[0] == 1 { output.Append(solver.Query( queryStartIndex: command[1] - 1, queryEndIndex: command[2] - 1)); output.AppendLine(); } } } Console.Write(output); }