10726 - Coco Monkey

All about problems in Volume 107. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Arm.Turbo
New poster
Posts: 21
Joined: Wed Aug 11, 2004 1:20 pm

10726 - Coco Monkey

Post 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?
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

Yeah, there is an analytical solution. Hint: for fixed S and M, look for a pattern in the possible values of C.
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post 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?
Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post 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).
circle
New poster
Posts: 1
Joined: Tue Sep 14, 2004 4:36 pm

Post by circle »

I solve it but WA.
Please can anyone give me some critical I/O who got AC.
failor
New poster
Posts: 6
Joined: Mon Dec 05, 2005 11:10 am

how to?

Post 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:
failor
New poster
Posts: 6
Joined: Mon Dec 05, 2005 11:10 am

Post 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:
lonelyone
Learning poster
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Post by lonelyone »

What's the analytical solution
Any hint in detail, please..
rieo
New poster
Posts: 9
Joined: Tue Jul 04, 2006 10:46 am
Location: Taiwain

Post 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..
sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post 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.
Post Reply

Return to “Volume 107 (10700-10799)”