-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06_loops_2.java
More file actions
35 lines (28 loc) · 787 Bytes
/
06_loops_2.java
File metadata and controls
35 lines (28 loc) · 787 Bytes
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
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) {
Scanner sc = new Scanner(System.in);
int length = sc.nextInt();
for(int i=0; i<length; i++)
{
int a = sc.nextInt();
int b = sc.nextInt();
int n = sc.nextInt();
for(int j =0;j<n;j++) {
System.out.print(getValue(a,b,j)+" ");
}
System.out.println();
}
}
static int getValue(int a,int b, int n) {
int sum = a;
for(int z=n;z>=0;z--) {
sum = sum + ((int) Math.pow(2,z))*b;
}
return sum;
}
}