-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFor-Loop.java
36 lines (31 loc) · 917 Bytes
/
For-Loop.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
import java.util.*;
import java.io.*;
import java.lang.*;
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[] arr = new int[n];
for (int j = 1; j < n+1; j++)
{
int currvalue = 0;
for (int k = 0 ; k < j; k++)
{
currvalue = currvalue + (int)((Math.pow(2, k)) * b);
}
int s = a + currvalue;
arr[j-1] = s;
}
for(int z=0; z < n; z++)
{
System.out.print(arr[z] + " ");
}
System.out.println("");
}
in.close();
}
}