Search found 3 matches

by iggy
Mon May 05, 2008 2:21 pm
Forum: Volume 102 (10200-10299)
Topic: 10212 - The Last Non-zero Digit.
Replies: 63
Views: 38913

Re: 10212 - The Last Non Zero Digit

I still wonder how people get this calculated in under 0.002s.. What worked for me was to first cache pairs (c, d) for every x: 1..20'000'000 such that x = 2^a * 5^b * r; c = a - b; // easily calculated d = r % 10; Then considering: if x -> (c, d) then lastnonzerodigit(x) = { d, if c = 0 | 5, if c<0...
by iggy
Mon May 05, 2008 11:25 am
Forum: Volume 102 (10200-10299)
Topic: 10228 - Star not a Tree?
Replies: 4
Views: 3166

Re: 10228 - A Star not A Tree

Gradient descent with centroid as a starting point works well too.
Is there a geometrical solution though?
by iggy
Mon May 05, 2008 11:08 am
Forum: Volume 102 (10200-10299)
Topic: 10246 - Asterix and Obelix
Replies: 29
Views: 13232

Re: 10246 - Asterix and Obelix

A simpler example where single Floyd-Warshall is too greedy: it discards shorter path over city 3 because it's expensive to party there, even though a more expensive city (5) is inevitably encountered later. 5 5 1 10 10 20 10 30 1 2 2 1 3 1 2 4 2 3 4 1 4 5 5 1 5 I'm guessing running the algorithm th...

Go to advanced search