-
Notifications
You must be signed in to change notification settings - Fork 0
/
ManasaStones.java
43 lines (30 loc) · 1.09 KB
/
ManasaStones.java
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
33
34
35
36
37
38
39
40
41
42
43
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int cases = 0; cases < n; cases++){
int steps = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
HashSet<Integer> set = new HashSet<Integer>();
for(int run = 0; run < steps; run++){
int sum = 0;
sum += ((steps - run - 1) * a + run * b);
set.add(sum);
}
TreeSet<Integer> sorted = new TreeSet<Integer>();
sorted.addAll(set);
for(int item: sorted){
System.out.print(item + " ");
}
System.out.println();
}
}
}
//Math