Another editorial

Правка en2, от spookywooky, 2020-05-09 12:46:21

In [ProblemlinkA] there is a definition of a number to be "round". To create the set of round numbers we need to observe that every single digit of the initial number can be used to create a round number. Just add the numbers of zeros according to the position of the digit. ie "123" becomes "100 20 3". [SubmissionA]

[ProblemlinkB] ask us to create a set of numbers where the sum equals a given n. The summands are limited to be all odd or all even, and the number of summands is given as k. So it turns out it is a case work of n and k beeing odd or even.

if n is odd and k is even there is no solution, since an even number of summands of same parity will allways give and even sum.

if n is odd and k is odd we can construct a solution by using 1s and a last, bigger number as $$$n-k+1$$$. But we need to check if $$$k>=n$$$ since if not there is no solution.

if n is even and k is even, too, the previus solution works, too.

Last case n is even and k is odd. Here we cannot use 1s as summands, because if we do the sum will be odd, but it must be even. So we need to use 2s intead of 1s. Therefor we need to check that $$$k*2<=n$$$ and use last number as $$$n-2*(k-1)$$$ [SubmissionB]

[ProblemlinkC] is a bit mathy. We need to find a number not dividable by n where $$$k-1$$$ lower numbers exist not divisable by k. How to do that? To tell for a given number how much lower/equal numbers exist being divi by n is simple, it is: $$$k-k/n$$$ Since every nth number is divi by n we can use blocks of size n to calculate the solution. A block of n numbers has $$$n-1$$$ numbers not divi by n. So we need to use k/(n-1) blocks, plus the remainder of the blocksize. There is a flaw whith this, if the remainder is zero. To workarround that, we can subtract one from solution, and then add one until solution fits. I hope there is a simpler solution, too ;) [SubmissionC]

[ProblemlinkD] has lengthy statement to make all points clear. We just need to implement all details. I did using a left pointer and a right one. Then, in a loop, I add elements from left according to the rules, and then elements from the right, until left and right meet somewhere in the middle. There the loop ends and the collected numbers can be printed. [SubmissionD]

Теги div4, editorial, beginner, 1352

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en30 Английский spookywooky 2020-05-10 00:38:25 6 Tiny change: 'hat for $n<4$ there i' -> 'hat for $n{\lt}4$ there i'
en29 Английский spookywooky 2020-05-10 00:30:06 62
en28 Английский spookywooky 2020-05-09 21:48:50 4197
en27 Английский spookywooky 2020-05-09 19:36:06 0 (published)
en26 Английский spookywooky 2020-05-09 19:09:36 61
en25 Английский spookywooky 2020-05-09 19:06:35 512
en24 Английский spookywooky 2020-05-09 18:57:14 6 Tiny change: ' k is even, too, the previ' -> ' k is even the previ'
en23 Английский spookywooky 2020-05-09 18:54:33 50
en22 Английский spookywooky 2020-05-09 18:42:53 10
en21 Английский spookywooky 2020-05-09 18:39:56 572
en20 Английский spookywooky 2020-05-09 18:38:14 527
en19 Английский spookywooky 2020-05-09 18:35:30 760
en18 Английский spookywooky 2020-05-09 18:32:26 764
en17 Английский spookywooky 2020-05-09 18:29:52 760
en16 Английский spookywooky 2020-05-09 18:28:16 233
en15 Английский spookywooky 2020-05-09 18:25:31 1030
en14 Английский spookywooky 2020-05-09 18:23:47 365
en13 Английский spookywooky 2020-05-09 18:18:37 640
en12 Английский spookywooky 2020-05-09 14:20:14 2 Tiny change: 'ize $4 + n%%4$\n\nNot' -> 'ize $4 + n\%4$\n\nNot'
en11 Английский spookywooky 2020-05-09 14:18:26 7 Tiny change: 'ize $4 + n mod 4$\n\nNote' -> 'ize $4 + n%%4$\n\nNote'
en10 Английский spookywooky 2020-05-09 14:17:49 10 Tiny change: ' of size $n%4+4$\n\nNote' -> ' of size $4 + n mod 4$\n\nNote'
en9 Английский spookywooky 2020-05-09 14:16:36 2
en8 Английский spookywooky 2020-05-09 14:15:03 13
en7 Английский spookywooky 2020-05-09 14:11:06 4
en6 Английский spookywooky 2020-05-09 14:10:17 63
en5 Английский spookywooky 2020-05-09 14:07:27 27
en4 Английский spookywooky 2020-05-09 14:00:12 1352
en3 Английский spookywooky 2020-05-09 13:04:14 1279
en2 Английский spookywooky 2020-05-09 12:46:21 8
en1 Английский spookywooky 2020-05-09 12:43:31 2273 Initial revision (saved to drafts)