ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2095. Scrum

WA 5
Posted by Kogut.Ivan 10 Jul 2016 15:14
Can you give me some tests, please? I don't understand why WA.
Re: WA 5
Posted by Jane Soboleva (SumNU) 10 Jul 2016 17:44
1 10^9 should be 35682 (apparently? i might be wrong)

If you have a few spare gigabytes of RAM, you can simulate the thing by yourself. Initially we have 1 2 3 ... 10^9, after 1st step 1 3 5 etc (+2 +2 +2 etc), after 2nd step it's 1 3 7 9 13 15 (+2 +4 +2 +4 +2 +4 etc), after 3rd step it's 1 3 7 13 15 19 25 27 31 (+2 +4 +6 +2 +4 +6 +2 +4 +6 etc). Only on 4th step it becomes complicated and loses pattern. So for further simulation, you need 1 array of 10^9 / 2 / 2 + 1 4-byte integers from 3rd step (1 and [+2 +4 +6 cycle]), which is ~1GB, and another ~1GB array to copy elements into.

I also found the sequence on OEIS: https://oeis.org/A000960, but still, i can't quite understand some things. For example:
«To get n-th term, start with n and successively round up to next 2 multiples of n-1, n-2, ..., 1 (compare to Mancala sequence A002491). E.g.: to get 11th term: 11->30->45->56->63->72->80->84->87->90->91; i.e., start with 11, successively round up to next 2 multiples of 10, 9, .., 1. - Paul D. Hanna, Oct 10 2005»
— what is this even? I have a hard time understanding what exactly is done here...
Re: WA 5
Posted by Felix_Mate 10 Jul 2016 18:35
10 18 => 1
666 999 => 6
13 100000 => 354
123456789101112 12345678910111213 => 112837915
1 1000000000 => 35682
1 1000000000000 => 1128378

Edited by author 10.07.2016 18:37
Re: WA 5
Posted by Kogut.Ivan 10 Jul 2016 21:05
Thanks a lot!!! I got AC.
Felix_Mate wrote 10 July 2016 18:35
10 18 => 1
666 999 => 6
13 100000 => 354
123456789101112 12345678910111213 => 112837915
1 1000000000 => 35682
1 1000000000000 => 1128378

Edited by author 10.07.2016 18:37
Re: WA 5
Posted by MrBones 21 Jan 2017 01:02

It means to get n-th number you need to increase n step-by-step. At each step you increase your current number twice to the nearest number divisible by n - 1, n - 2, ..., 1 depending on each step you are now.

Example: n = 11, nearest to 11 divisible by 10 is 20, next one is 30. nearest to 30 dibisible by 9 is 36 and next one is 45. And so on 11->30->45->56->63->72->80->84->87->90->91
Jane Soboleva (SumNU) wrote 10 July 2016 17:44
1 10^9 should be 35682 (apparently? i might be wrong)

If you have a few spare gigabytes of RAM, you can simulate the thing by yourself. Initially we have 1 2 3 ... 10^9, after 1st step 1 3 5 etc (+2 +2 +2 etc), after 2nd step it's 1 3 7 9 13 15 (+2 +4 +2 +4 +2 +4 etc), after 3rd step it's 1 3 7 13 15 19 25 27 31 (+2 +4 +6 +2 +4 +6 +2 +4 +6 etc). Only on 4th step it becomes complicated and loses pattern. So for further simulation, you need 1 array of 10^9 / 2 / 2 + 1 4-byte integers from 3rd step (1 and [+2 +4 +6 cycle]), which is ~1GB, and another ~1GB array to copy elements into.

I also found the sequence on OEIS: https://oeis.org/A000960, but still, i can't quite understand some things. For example:
«To get n-th term, start with n and successively round up to next 2 multiples of n-1, n-2, ..., 1 (compare to Mancala sequence A002491). E.g.: to get 11th term: 11->30->45->56->63->72->80->84->87->90->91; i.e., start with 11, successively round up to next 2 multiples of 10, 9, .., 1. - Paul D. Hanna, Oct 10 2005»
— what is this even? I have a hard time understanding what exactly is done here...
Re: WA 5
Posted by Jane Soboleva (SumNU) 21 Jan 2017 01:51
Thank you! Your explanation is much more clear. Original should probably have "the 2nd closest multiple" instead of "next 2 multiples", would make more sense.
Re: WA 5
Posted by Амир Меннибаев 20 Mar 2017 20:44
Why isn't wrong?
10 18 => 1

Edited by author 20.03.2017 20:45