Skip to content
Advertisement

Given three integers a, b, and n,output the following series: a+20b,a+20b+21b,……,a+20b+21b+…+2n−1ba+20b,a+20b+21b,……,a+20b+21b+…+2n−1b

Constraints:

  • 0≤t≤500
  • 0≤a,b≤50
  • 1≤n≤15

Sample Input:

JavaScript

Sample Output

JavaScript

This works in my IDE but when I try it in an online editor in hackerrank.com it throws an exception:

Exception in thread “main” java.util.NoSuchElementException: No line foundat java.util.Scanner.nextLine(Scanner.java:1585)at Solution.main(Solution.java:24)

Please explain why this happens.Thanks!

JavaScript

Advertisement

Answer

Remove iput.nextLine(); on line 24 so that no extra reading will happen.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement