Search found 193 matches

by turuthok
Fri Aug 08, 2003 7:08 pm
Forum: Volume 105 (10500-10599)
Topic: 10514 - River Crossing
Replies: 14
Views: 3685

This is a really nice problem. It looks overwhelming at first ... but when you relax a little bit, ... it actually goes down to "distance between 2 segments" problem.

I got the segment-segment distance from http://www.softsurfer.com ...

-turuthok-
by turuthok
Fri Aug 08, 2003 6:59 pm
Forum: Volume 101 (10100-10199)
Topic: 10154 - Weights and Measures
Replies: 60
Views: 40254

Sequence for RedScorpion's input ...

Code: Select all

[2 1000]
[1 1000]
[500 901]
[10 500]
[152 199]
[3 40]
[20 30]
[1 2]
-turuthok-
by turuthok
Thu Aug 07, 2003 7:19 am
Forum: Volume 105 (10500-10599)
Topic: 10514 - River Crossing
Replies: 14
Views: 3685

Larry, I got different result on the middle red line:

upper red-line -> 2.353394
middle red-line -> 2.414039
bottom red-line -> 1.488417

-turuthok-
by turuthok
Wed Aug 06, 2003 8:37 pm
Forum: Volume 104 (10400-10499)
Topic: 10422 - Knights in FEN
Replies: 49
Views: 17797

Observer, I lost my code for this one ... but I used BFS approach. As far as I can recall, I started from target state, find possible moves that are one-step away ... I repeated that it until at most 10 steps. I stored each possible move into a hash-list. After this, I just dealt with the inputs, if...
by turuthok
Tue Aug 05, 2003 5:32 am
Forum: Algorithms
Topic: Sine, cosinus, ...trigonometry
Replies: 2
Views: 1750

It's about the argument which is in "rad" instead of "degree".

30 degree = 30 * pi / 180 rad ...

-turuthok-
by turuthok
Sun Aug 03, 2003 9:27 pm
Forum: Algorithms
Topic: Big numbers; Maybe easy, but not for me.
Replies: 9
Views: 3739

For addition of long-digits numbers like you mentioned, we might have to upgrade our current "base-10" perspective to some higher base ... like "base-10^n" where n > 1, ... just be careful on overflows if we use bigger base. That would already be an improvement ...

-turuthok-
by turuthok
Sun Aug 03, 2003 6:48 am
Forum: Volume 1 (100-199)
Topic: 142 - Mouse Clicks
Replies: 58
Views: 6264

Morning, no problem at all ...

Oh yes, was that your real judge-id in the posted-code above, ... make sure you don't disclose it ... someone might use it for nasty purpose.

-turuthok-
by turuthok
Sun Aug 03, 2003 6:39 am
Forum: Volume 1 (100-199)
Topic: 142 - Mouse Clicks
Replies: 58
Views: 6264

Hmm, ... scanf("%s") won't necessarily read until the end of line ... it would read the first token it sees ... it will stop scanning when it sees a whitespace.

Try it out ... I'm sure you'll get it.

-turuthok-
by turuthok
Sun Aug 03, 2003 6:34 am
Forum: Volume 1 (100-199)
Topic: 142 - Mouse Clicks
Replies: 58
Views: 6264

That should be simple, ... first, you can scanf("%s") ... and then based on the first character of s, you do another scanf() ... right ??? scanf("%s", s); switch(s[0]) { case '#': return 0; case 'I': scanf("%d %d", &a, &b); /* continue your code ... */ case 'R': scanf("%d %d %d %d", &a, &b, &c, &d);...
by turuthok
Sun Aug 03, 2003 5:35 am
Forum: Volume 1 (100-199)
Topic: 142 - Mouse Clicks
Replies: 58
Views: 6264

You can also use:

Code: Select all

scanf("%s", str);
Your expected character will be in str[0].

-turuthok-
by turuthok
Fri Jul 04, 2003 11:41 am
Forum: Volume 105 (10500-10599)
Topic: 10522 - Height to Area
Replies: 32
Views: 15443

Output for Sample Input:
-----------------------------

1517.456
2219.941
311.804
These are invalid inputs!
by turuthok
Fri Jul 04, 2003 4:55 am
Forum: Algorithms
Topic: [Resolved]: O(n) for sum of consecutive terms of 1xn array
Replies: 5
Views: 2196

I should have tested before I posted ... :( ...

The algo seems okay, but variable "start" doesn't work right ... hehehe, I'm sure you can still get the idea.

-turuthok-
by turuthok
Fri Jul 04, 2003 4:49 am
Forum: Algorithms
Topic: [Resolved]: O(n) for sum of consecutive terms of 1xn array
Replies: 5
Views: 2196

Ooops, sorry ... we don't need another array, but we just need an accumulator ... For example: -7, -9, 88, -30, -50, 90, -1, -2, -4, 5, 30, -21 Algo: acc = 0; max = 0; start = -1; for (i = 0; i < N; i++) { acc += a[i]; if (acc > max) { max = acc; // update our max. range if (start == -1) start = i; ...
by turuthok
Fri Jul 04, 2003 12:21 am
Forum: Algorithms
Topic: [Resolved]: O(n) for sum of consecutive terms of 1xn array
Replies: 5
Views: 2196

You can accumulate each element to one array, and observe this array instead of the original array.

-turuthok-
by turuthok
Sat Jun 28, 2003 12:02 am
Forum: C++
Topic: [Resolved]memset problems
Replies: 3
Views: 1762

memset(arr, 0, sizeof(arr)) works for me ...

-turuthok-

Go to advanced search