-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathProgram.cs
More file actions
32 lines (24 loc) · 905 Bytes
/
Program.cs
File metadata and controls
32 lines (24 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Linq;
namespace Manasa_and_Stones {
class Program {
public static int[] Stones(int n, int a, int b) {
int[] lastStonesValues = new int[n];
for (int i = 0; i < n; i++) {
lastStonesValues[i] = (i * a) + ((n - 1 - i) * b);
}
Array.Sort(lastStonesValues);
return lastStonesValues.Distinct().ToArray();
}
static void Main(string[] args) {
int T = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < T; i++) {
int n = Convert.ToInt32(Console.ReadLine());
int a = Convert.ToInt32(Console.ReadLine());
int b = Convert.ToInt32(Console.ReadLine());
int[] result = Stones(n, a, b);
Console.WriteLine("{0}", string.Join(" ", result));
}
}
}
}