You are viewing a single comment's thread. Return to all comments →
import java.util.*; import java.util.stream.*; import java.io.*; class Solution{ public static void main(String []argh){ Scanner in = new Scanner(System.in); int t=in.nextInt(); for(int i=0;i<t;i++){ int a = in.nextInt(); int b = in.nextInt(); int n = in.nextInt(); int number=0; for(int x=0;x<n;x++){ if(x==0){ number=(a+(b*(int)Math.pow(2,x))); }else{ number+=(b*(int)Math.pow(2,x)); } System.out.format("%d ",number); } System.out.println(); } in.close(); } }
Java Loops II
You are viewing a single comment's thread. Return to all comments →