An Animal Contest 6 P1 - Workout Routine

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type

Kyriakos Grizzly wants to create a new workout routine over the course of the next N days. In order for a workout routine to be good, the amount of weights he lifts each day must be pairwise distinct, and must be in the range [1,10^9]. Furthermore, the sum of the weights over the N days must be divisible by K for maximal gains. Can you create a good workout routine for Kyriakos, or let him know that it's impossible?


1 \le N, K \le 10^6

Subtask 1 [20%]

1 \le N \times K \le 10^9

Subtask 2 [80%]

No additional constraints.

Input Specification

The only line of input contains 2 integers N and K.

Output Specification

If no good workout routine exists output -1.

Otherwise, output one line containing N integers. The integers must all be distinct and must all be in the range [1,10^9], and their sum must be divisible by K.

Sample Input

6 9

Sample Output

2 5 7 3 10 9


  • 0
    Codester  commented on March 23, 2022, 1:59 a.m.

    Is there a simple reason why I might be getting presentation error? My code worked for the first subtask but not for the second subtask and I'm not sure if it's an error in formatting or the logic. Thanks!

    • 0
      BalintR  commented on March 23, 2022, 3:37 a.m.

      From the contest page:

      Checkers: unless otherwise specified, identical. The contest will follow the standard convention of having all lines terminate in a \n character, with no trailing whitespace.

      Most of your submissions don't print any newline characters.

      • -2
        notAkki  commented on March 31, 2022, 4:28 p.m. edit 3

        I looked at the previous comment because I was having the same problem, but even now, I still can't manage to avoid the presentation errors. Can someone please try to help me out? Thanks!

        EDIT: I figured out how to avoid the presentation error

        • -2
          Codester  commented on April 11, 2022, 11:21 a.m.

          Could you explain how you avoided it? Thanks!

          • -1
            uselessleaf  commented on April 11, 2022, 2:50 p.m. edited

            Your 20/100 submission has the right idea regarding presentation, as you are printing "\n" at the end of the line. That one gets WA on subtask 2 due to how all the numbers you output must be in the range [1, 10^9], but if N=K=10^6 (which can happen in subtask 2), your program will output 10^{12}. As for your other submissions, as BalintR pointed out, you are not printing "\n" at the end of your line. You should also check that the values are separated by one space, and also that there are no trailing spaces.

            If you still need help, you should ask in the DMOJ Discord.