Editorial for An Animal Contest 6 P1 - Workout Routine


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: dxke02

Hint

The answer is never -1.

Subtask 1

The intended solution for this subtask is to output the sequence K, 2K, 3K, \dots, NK. Since all terms are divisible by K, their sum is also divisible by K.

Subtask 2

One possible answer is to first generate the sequence 1, 2, \dots, N-1, then fill in the last element with any element that makes the sum divisible by K.


Comments


  • 0
    Humanthe2nd  commented on Oct. 19, 2024, 2:30 a.m.

    As as alternative I used, K could be doubled until it is strictly greater than N (as multiples of K are divisible by K). Then for each integer X in [1,N/2], X and K-X could be used. In addition if N is odd then K itself could be added.