Java Loops II - Java Question
Java Loops II - Java Question
Java Loops II
by Shafaet
You are given queries in the form of , , and . For each query, print the series corresponding to the g
single line of space-separated integers.
Input Format
Constraints
Output Format
For each query, print the corresponding series on a new line. Each series must be printed in order as a si
integers.
Sample Input
2
0 2 10
5 3 5
Sample Output
Explanation
Once we hit , we print the first ten terms as a single line of space-separated integers.
We then print each element of our series as a single line of space-separated values.
Current Buffer (saved locally, editable) Java 7
1 ▾import java.util.*;
2 import java.io.*;
3
4 ▾class Solution{
5▾ public static void main(String []arg){
6 Scanner in = new Scanner(System.in);
7 int t=in.nextInt();
8▾ for(int i=0;i<t;i++){
9 double a = in.nextInt();
10 int b = in.nextInt();
11 int n = in.nextInt();
12 ▾ for(double j=0;j<n;j++){
13 a = a + (Math.pow(2,j)*b);
14 int myInt = (int) a;
15 System.out.print(myInt+" ");
16 }
17 System.out.print("\n");
18 }
19 in.close();
20 }
21 }
22