Search found 12 matches

by patsp
Sat Nov 19, 2011 2:58 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

shaon_cse_cu08 wrote:Hello every1... My code gives Correct answer for every Input i have tested... But I can't understand Why WA... Plz help me... :oops:
I can't say why your approach does not work, but try this case:

input:

Code: Select all

1
36 4680
My solution outputs 520, while yours outputs 4680.
by patsp
Fri May 13, 2011 12:48 pm
Forum: Volume 114 (11400-11499)
Topic: 11402 - Ahoy, Pirates!
Replies: 45
Views: 24487

Re: 11402 - Ahoy, Pirates

@chengouxuan

I tried it with segment tree but got TLE. I don't know how to do the inversion fast.

Can you explain how you solved it with sqrt(n) X sqrt(n) table??
by patsp
Fri Jan 21, 2011 10:57 pm
Forum: Volume 113 (11300-11399)
Topic: 11394 - Digit Blocks
Replies: 18
Views: 11426

Re: 11394 - Digit Blocks

I tried to solve this problem with the state dp[1<<16][5] as proposed, but getting TLE. Maybe some tips on how to solve it with 16X16X5 memo?

EDIT: With the help of Topcoder msg555 I am able to solve this problem now. See here for details.
by patsp
Wed Dec 01, 2010 7:25 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

What exactly do you want explained? Problem statement?
For some tips on how to solve it, take a look at some posts above.
by patsp
Tue Nov 23, 2010 8:19 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

Here are some testcases, hope they help.

input:
23
2 6
32 1760
7 16
59 44132
218 8066
846 192042
469 28609
676 29068
5 2855
458 115874
77 4081
237 68019
697 14637
74 72298
493 340170
732 104676
355 103305
878 179990
357 111384
157 90275
973 2919
28 6188
429 27456

output:
3
55
NO SOLUTION
748
37 ...
by patsp
Tue Nov 02, 2010 10:22 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

Ah, sure, I thought C could be a prime number... but then it cannot be an lcm..

But what do you mean with check it and then forget it. For finding B, I currently use the fact that the lcm of two numbers is always the product of the prime factors which occur more often in the two numbers, so I don't ...
by patsp
Tue Nov 02, 2010 10:03 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

I tried it with only primes. With my current algorithm for finding the value of B, I need the primes from 2 to 10^7.

How can I calculate B if I don't know the factors of A and C.
by patsp
Tue Nov 02, 2010 9:44 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

Now I'm trying to optimize my solution. I currently use trial division and C++ STL map to store how many times each factor occurs.

Some tips or references on how I could optimize would be great. Thanks in advance.
by patsp
Mon Nov 01, 2010 9:08 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

Re: 11889 - Benefit

Thanks Angeh, now I could solve it.
by patsp
Mon Nov 01, 2010 6:17 pm
Forum: Volume 118 (11800-11899)
Topic: 11889 - Benefit
Replies: 27
Views: 14845

11889 - Benefit

I'm not able to come up with a solution...
Obviously, the brute force approach is too slow. My next step was that I tried to come up with a mathematical solution, but without success.

Can anyone help?
by patsp
Mon Nov 01, 2010 6:14 pm
Forum: Volume 118 (11800-11899)
Topic: 11888 - Abnormal 89's
Replies: 11
Views: 8299

Re: 11888 - Abnormal 89's

How to solve this problem in O(N) ??
by patsp
Tue Sep 21, 2010 9:09 pm
Forum: Volume 118 (11800-11899)
Topic: 11847 - Cut the Silver Bar
Replies: 11
Views: 5808

Re: 11847 Cut the Silver Bar

I thought the solution should be 2 if n > 3, 0 if n == 1, 1 if n == 2 or n == 3

2 if n > 3: Cut one piece of size 1, another piece of size 2, then we have 3 pieces of size 1,2, n-3
On the first day the miner can give the n-3 size piece, then the 1 size piece and the next n-2 days he can give 2 and ...

Go to advanced search