## VM7WC '16 #5 Bronze - Jayden Watches Videos

View as PDF

Points: 3
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Jayden is a little kid who likes to watch videos on Youtube. However, the internet connection is slow, and the video will stop playing at certain times to "buffer", or load more of the video.

The video has a length of seconds. Let be the amount of seconds it takes Jayden's internet connection to download one second of the video. Jayden wants to watch the video uninterrupted, so he decides to wait seconds to let the video buffer before playing it.

Since Jayden is impatient, he wants to start watching at the earliest time possible that allows the video to play through without interruption. Help him find the smallest amount of time !

#### Input Specification

On a single line will be the two integers (Youtube videos are usually limited to fifteen minutes in length) and .

#### Output Specification

On a single line, output the integer .

#### Sample Input 1

5 3

#### Sample Output 1

10

#### Sample Input 2

1 3

#### Sample Output 2

2

• commented on Nov. 6, 2017, 11:07 a.m.

my program is correct !!! but i get a wg

• commented on Nov. 6, 2017, 6:02 p.m.

Your math is wrong, I have tested and compiled it in Java and I also got WA.

The formula in your code only works for the two test cases above, but not for the test cases when you submit your solution.

• commented on Feb. 9, 2016, 2:11 p.m. edit 2

For some reason when I enter the sample input into my code the answer appears one line below where it should appear. So like this:

5 3
// gap
10

Is there any way to output my answer directly below the input so there is no gap? I am just using a System.out.print(); to output my answers. I think the gap is why I keep getting invalid return when I try to submit my code.

• commented on Feb. 7, 2016, 8:59 p.m.

I've been at this problem for 3 hours now.

For some reason when I press the "Copy" button in the top right corners of the sample outputs and I enter it into the console, it skips a line. For example,

Console: 5 3

10

Do you see the gap between the "5 3" and the "10"?

when I enter it in manually there is no gap.

This is causing me a lot of problems since the online judge is trying to read the space in between the "5 3" and the "10" resulting in a "java.util.NoSuchElementException".

At least I think this is what is going on. Does anybody know how I can solve this issue? It seems I am the first to encounter this so it is probably a problem on my end.

• commented on Feb. 7, 2016, 9:14 p.m.

The judge doesn't read the input, only the output. The "java.util.NoSuchElementException" exception is on your side. If you're using Scanner, are you using both .nextLine() and .nextInt()? If you're still having trouble, try using BufferedReader -- I had no problem with it.

• commented on Feb. 7, 2016, 10:41 p.m. edited

BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String[] tokens = in.readLine().split(" "); int a = Integer.parseInt(tokens[0]); int b = Integer.parseInt(tokens[1]);

I used the above format in order to get to the input into Integer form but I keep getting this error when trying to parse the string into an integer form:

Exception in thread "main" java.lang.NumberFormatException: For input string: ""

• commented on Feb. 7, 2016, 11:31 p.m.

Strange... I get AC when using your input.

Perhaps instead of using .split(), use StringTokenizer. If there are two spaces between 5 and 3 (I.E. "5 3"), it would yield a NumberFormatException.

• commented on Feb. 8, 2016, 12:17 a.m.

I tried using the StringTokenizer but I am still back at the same problem "nullpointerexception".

When I manually type in the numbers the output appears like so:

5 3 10

But when I copy the numbers the output appears like this:

5 3

10 10

I have no idea what the problem is. Also I am using StringTokenizer like so (may or may not be right):

StringTokenizer st = new StringTokenizer(input.readLine());

    while (st.hasMoreElements())
{
videoLength = Integer.parseInt(st.nextToken());
dSpeed = Integer.parseInt(st.nextToken());
}
• commented on Feb. 8, 2016, 12:48 a.m.

Why are you using a loop to read a single line input?