/**
 * 
 */
package algorithms.implementation;

import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Challenge: https://www.hackerrank.com/challenges/manasa-and-stones
 * 
 * @author Sudharsanan Muralidharan
 */
public class ManasaAndStones {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int t = in.nextInt();

    while (t-- > 0) {
      int n = in.nextInt() - 1;
      int a = in.nextInt();
      int b = in.nextInt();
      Set<Integer> valuesSet = new LinkedHashSet<Integer>();

      int min = Math.min(a, b);
      int max = Math.max(a, b);

      valuesSet.add(n * min);
      for (int i = 0; i < n; i++) {
        valuesSet.add((max * (i + 1)) + (n - i - 1) * min);
      }

      for (Integer val : valuesSet) {
        System.out.print(val + " ");
      }
      System.out.println();

    }
    in.close();
  }
}

@@ -62,69 +62,15 @@
 til.
-LinkedHashSet;%0Aimport java.util.Scanner;%0Aimport java.util.Set
+Scanner
 ;%0A%0A/
@@ -441,69 +441,8 @@
 t();
-%0A      Set%3CInteger%3E valuesSet = new LinkedHashSet%3CInteger%3E();
 %0A%0A  
@@ -510,29 +510,120 @@
 %0A%0A      
-valuesSet.add
+if(a == b) %7B%0A        System.out.println(n * a);%0A        continue;%0A      %7D%0A      %0A      System.out.print(
 (n * min
@@ -619,24 +619,31 @@
 nt((n * min)
+ + %22 %22)
 ;%0A      for 
@@ -680,21 +680,25 @@
     
-valuesSet.add
+System.out.print(
 ((ma
@@ -734,85 +734,8 @@
 min)
-;%0A      %7D%0A%0A      for (Integer val : valuesSet) %7B%0A        System.out.print(val
  + %22
@@ -743,24 +743,25 @@
 %22);%0A      %7D%0A
+%0A
       System

Solve even without using HashSet