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.
importjava.io.*;importjava.util.*;publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */intq,a,b,n;Scannerscan=newScanner(System.in);q=scan.nextInt();// read the buffer \n in input stream and ignorescan.nextLine();for(inti=0;i<q;i++){Stringline=scan.nextLine();String[]tokens=line.split(" ");a=Integer.parseInt(tokens[0]);b=Integer.parseInt(tokens[1]);n=Integer.parseInt(tokens[2]);intex=0;for(intj=0;j<=n-1;j++){// caching the previous output to avoid repeated computationsex+=(int)(Math.pow(2,j)*b);System.out.print(a+ex);System.out.print(" ");}System.out.println();}scan.close();}}
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 →