-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJava Loops II
30 lines (26 loc) · 973 Bytes
/
Java Loops II
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
We use the integers , , and to create the following series:
You are given queries in the form of , , and . For each query, print the series corresponding to the given , , and values as a single line of space-separated integers.
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int t=in.nextInt();
int value = 0;
for(int i=0;i<t;i++){
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();
value = (int) (a + Math.pow(2, 0) * b);
System.out.print(value + " ");
for (int j = 1; j < n; j++) {
value = (int) (value + Math.pow(2, j) * b);
// a + 2 << 0 * b + 2 << 1 * b
System.out.print(value + " ");
}
System.out.println();
value = 0;
}
in.close();
}
}