20240708


1983A. Array Divisibility

It felt good to have this problem solved.

for _ in range(int(input())):
    n = int(input())
    print(" ".join([str(x) for x in range(1, n + 1)]))

My Thought Process

The easiest way to make the sum of numbers, whose indices are multiple of k, divisible by k, we can pick multiples of k for the numbers.

For example, when thinking about k = 3 and 10 input numbers, we need to pick {3a, 3b, 3c} where a, b, and c are integers for indices 3, 6, and 9, so that, the sum will be 3(a + b + c) which is divisible by 3.

I first thought of multiplying corresponding indices by 1, 2, 3, …, n, but after consideration, found out the array [1, 2, …, n] meets the condition!


Cheese 30g Protein shake 10g Eggs 10g

Total carbohydrate 50g


MUST:

TODO:


index 20240707 20240709