forked from 3point141/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.java
More file actions
41 lines (32 loc) · 760 Bytes
/
loops.java
File metadata and controls
41 lines (32 loc) · 760 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
35
36
37
38
39
40
41
/* q->integer test cases
a-> integer
b-> integer
n-> integer
(a+2^0 . b),(a+2^0 . b +2^1 . b), ... , (a+2^0 . b + 2^1 . b + ... + 2^(n-1) . b)
hackerRank JAVA_lOOPS_II problem
*/
import java.io.*;
import static java.lang.Math.pow;
class loops
{
public static void main(String[] args) throws IOException
{
BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
int q=Integer.parseInt(x.readLine());
while(q>0)
{
int a=Integer.parseInt(x.readLine());
int b=Integer.parseInt(x.readLine());
int n=Integer.parseInt(x.readLine());
double sum=a+b;
System.out.print(a+b);
for(int i=1;i<n;i++)
{
sum=sum+(pow(2,i)*b);
System.out.print(" "+(int)sum);
}
System.out.println();
q--;
}
}
}