You are viewing a single comment's thread. Return to all comments →
Nice did a similar thing:
public class Solution { static String answer(int n, int one, int two) { int a = Math.min(one,two); int b = Math.max(one,two); if(a == b) return ((n-1)*a) + ""; String output = ""; for(int i = 0; i < n; i++) output += (a * (n-i-1) + b * i) + " "; return output; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int T = in.nextInt(); for(int a0 = 0; a0 < T; a0++){ System.out.println(answer(in.nextInt(), in.nextInt(), in.nextInt())); } in.close(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Manasa and Stones
You are viewing a single comment's thread. Return to all comments →
Nice did a similar thing: