Hackerrank - Java Solution - Java Loops II - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Tuesday, December 12, 2017

Hackerrank - Java Solution - Java Loops II

Hackerrank - Java Solution - Java Loops II

HackerRank Problem Solution

Problem Name - Java Loops II
Problem Link -  https://www.hackerrank.com/challenges/java-loops
Level - Introduction Challenges

Java Code
import java.util.Scanner;

class Solution{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        for (int i = 0; i < t; i++) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            int n = scan.nextInt();
            for (int j = 0; j < n; j++) {
                a += b * (int) Math.pow(2, j);
                System.out.print(a + " ");
            }
            System.out.println();
        }
        scan.close();
    }
}

Output:


Hackerrank - Java Solution - Java Loops II

Tags: HackerRank Online Judge Solution, HackerRank OJ Solution list, HackerRank Problems Solution, HackerRank solver, HackerRank all problem solution list, HackerRank solution in java, Hackerrank Java Solution, Hackerrank - Java Solution - Java Loops II

No comments:

Post a Comment