- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankJava0007.java
More file actions
Latest commit
34 lines (27 loc) · 711 Bytes
/
Copy pathHackerrankJava0007.java
File metadata and controls
34 lines (27 loc) · 711 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
importjava.util.Scanner;
publicclassHackerrankJava0007 {
publicstaticvoidmain(String[] args) {
// Java Loops II
// https://www.hackerrank.com/challenges/java-loops/problem?isFullScreen=true
Scannerin = newScanner(System.in);
intt = in.nextInt();
for (inti = 0; i < t; i++) {
inta = in.nextInt();
intb = in.nextInt();
intn = in.nextInt();
intlastValue = 0;
for (intj = 0; j < n; j++) {
intpowerOfTwo = (int) Math.pow(2, j);
if (j == 0) {
lastValue = a + powerOfTwo * b;
System.out.print(lastValue);
} else {
lastValue += powerOfTwo * b;
System.out.print(" " + lastValue);
}
}
System.out.println();
}
in.close();
}
}