We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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();
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Loops II
You are viewing a single comment's thread. Return to all comments →