Page 1 of 1

10726 - Coco Monkey

Posted: Wed Sep 22, 2004 10:46 am
by Arm.Turbo
I AC for this problem but my algorithm is slow. In ranklist for this problem i saw results 0.000 seconds. Is there exist analitical solution? I.e. simple equation?

Posted: Wed Sep 22, 2004 10:52 am
by Per
Yeah, there is an analytical solution. Hint: for fixed S and M, look for a pattern in the possible values of C.

Posted: Wed Sep 22, 2004 11:09 am
by little joey
Is zero coconuts acceptable at any stage? I think the text is not clear about it.
In other words:
- for 2 sailors and no monkeys, is 0 coconuts acceptable?
- for 2 sailors and one monkey, is 3 coconuts acceptable?

Guess I could try both alternatives, or did I overlook someting in the text?

Posted: Wed Sep 22, 2004 11:16 am
by Per
little joey wrote:- for 2 sailors and no monkeys, is 0 coconuts acceptable?
- for 2 sailors and one monkey, is 3 coconuts acceptable?
Yes in both cases. The only thing that matters is that every sailor gets M coconuts left after dividing the coconuts evenly in the S baskets (even if he gets 0 coconuts in each basket).

Posted: Mon Oct 04, 2004 3:08 pm
by circle
I solve it but WA.
Please can anyone give me some critical I/O who got AC.

how to?

Posted: Sat Dec 10, 2005 10:37 am
by failor
Per wrote:Yeah, there is an analytical solution. Hint: for fixed S and M, look for a pattern in the possible values of C.

I don't understand .
Will u help me to clear this? :roll:

Posted: Sat Dec 10, 2005 11:10 am
by failor
Per wrote:Yeah, there is an analytical solution. Hint: for fixed S and M, look for a pattern in the possible values of C.

What is analytical solution ?
Per or anyone else , will u tell me?
plz.
:roll:

Posted: Sat Feb 04, 2006 9:31 am
by lonelyone
What's the analytical solution
Any hint in detail, please..

Posted: Mon Aug 21, 2006 8:23 am
by rieo
can anyone explain case2 and case3?
in case 1, i can understand what it means..

but case 2: 10 -> means S=4 M=2 C=5+10=15, right?
15/4=3...3 left 9.. but 3!=M...
C should be 506, isn't it?
506/4=126...2 left 378
378/4=94.....2 left 282
282/4=70.....2 left 210
210/4=52.....2 left 156
156/4=39.....0

in case 3: 357, means S=6 M=4 C=1+357=358
358/6=59....4 left 295
295/6=49....1 <-- 1!=M

do i misunderstand this problem? can somebody teach me.. thx..

Posted: Wed Oct 04, 2006 1:22 am
by sclo
lonelyone wrote:What's the analytical solution
Any hint in detail, please..
Observe that if C is a solution, then C + S^(S+1) is also a solution.
So the solutions can be computed mod S^(S+1)
So generally, the solution are of the form S^(S+1)*a + b, where a,b are non-negative integers.
The key is to find out what b is.
Hint: b can be written in terms of S and M and it depends on the parity of S.