Java Loops II

  • + 2 comments
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import java.math.*;
    import java.util.regex.*;
    
     class HelloWorld {
    
        public static void main(String[] args) throws IOException{
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
            int i,j,k;
            double p;
            int t = Integer.parseInt(in.readLine());
            for(i=1;i<=t;i++)
                {
                    int a = Integer.parseInt(in.readLine());
                    int b = Integer.parseInt(in.readLine());
                    int n = Integer.parseInt(in.readLine());
    
                    for(j=0;j<n;j++)
                        {
                            int ans=a;
                            for(k=0;k<=j;k++)
                                {
    
                                    p=Math.pow(2,k);
                                    ans+=(p*b);
                                }
                            System.out.print(ans+" ");
                        }
                    System.out.println();
                }
        }
    }