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

View as PDF

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

Author:
Problem type

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, 4:07 p.m.

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

• commented on Nov. 6, 2017, 11: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, 7:11 p.m. edit 3

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. 8, 2016, 1:59 a.m. edited

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. 8, 2016, 2:14 a.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. 8, 2016, 3:41 a.m. edit 2
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
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. 8, 2016, 4:31 a.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, 5:17 a.m. edited

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, 5:48 a.m.

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