VM7WC '16 #5 Bronze - Jayden Watches Videos

View as PDF

Submit solution

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 L seconds. Let x 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 t 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 t!

Input Specification

On a single line will be the two integers L (1 \leq L \leq 900) (Youtube videos are usually limited to fifteen minutes in length) and x (1 \leq x \leq 50).

Output Specification

On a single line, output the integer t.

Sample Input 1

5 3

Sample Output 1

10

Sample Input 2

1 3

Sample Output 2

2

Comments


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

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


    • 1
      KevinLu  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.


  • 0
    yellowsn0w1004  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.


  • 0
    yellowsn0w1004  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.


    • 0
      jeffreyxiao  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.


      • 0
        yellowsn0w1004  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: ""


        • 0
          jeffreyxiao  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.


          • 0
            yellowsn0w1004  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());
                }

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

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