Search found 10 matches
- Fri Oct 28, 2005 6:00 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10023 - Square root
- Replies: 121
- Views: 30516
Here's how my algorithm looks: /* a = input number */ for (l = 0, u = a; l < u;) { x = (l + u) >> 1; /* break, if the following check can't be done in O(1) */ if (x * x > a) u = x; else l = x; } for (x = u;; x = y) if ((y = (x + a / x) >> 1) >= x) break; /* now x = root */ Excuse me, but how on ear...
- Sat Oct 22, 2005 5:34 pm
- Forum: Volume 1 (100-199)
- Topic: 180 - Eeny Meeny
- Replies: 34
- Views: 14958
Please correct PostScript version of Problem #180
In the HTML version of problem #180, input size has been changed from 500 to 1000000, which is a big change. And the PostScript version still remain unchanged. I download the PostScript version for printing out and work on it offline. Fortunately, I found out that it has been changed.... Please make...
- Mon May 09, 2005 6:54 am
- Forum: Volume 102 (10200-10299)
- Topic: 10245 - The Closest Pair Problem
- Replies: 92
- Views: 14536
WA, but I can't think of any reason...
#include <stdio.h> #include <stdlib.h> #include <math.h> #define MAX_PTS 10005 #define MAX_DIST 10000.0 #define EPSILON 1e-12 typedef struct point { double x; double y; int X_index; int Y_index; }point; int X[MAX_PTS]; int Y[MAX_PTS]; point pts[MAX_PTS]; int n_pts; int cmpX(const void *a, const voi...
- Mon May 09, 2005 3:18 am
- Forum: Volume 102 (10200-10299)
- Topic: 10245 - The Closest Pair Problem
- Replies: 92
- Views: 14536
Some simple cases
Here are some simple test cases: 3 0 0 10000 10000 20000 20000 5 0 2 6 67 43 71 39 107 189 140 6 -100 1 -100 -1 0 0 0 0 100 1 100 -1 1 10000 10000 6 -100 1 -100 2 0 0 0 1 2 1 3 5 5 1 0 0 2 35 7 1000 1000 1000 1001 12 1 0 0 2 35 7 77 92 1000 1000 1000 1001 10000 -4000 10005 2573 10007 8763 10007 8763...
- Wed Dec 15, 2004 4:24 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10054 - The Necklace
- Replies: 62
- Views: 33052
Anything Wrong?
I am getting WAs, but I can't see why. Or could someone give me some test cases? thanks. [c] #include <stdio.h> #include <stdlib.h> #include <string.h> int adj[51][51]; char e[2000]; char t[2000]; char c[2000]; /* degree counter of each vertex */ int d[51]; /* edge counter */ int D; /* Eulerian cycl...
- Mon Dec 13, 2004 3:32 pm
- Forum: Volume 102 (10200-10299)
- Topic: 10249 - The Grand Dinner
- Replies: 19
- Views: 12910
How does a greedy algorithm work ??
To jackie:
How does it work?
The straitforward greedy approach is destined to fail...
( scan from first table to last table, take a seat if the table isn't full yet... )
How does it work?
The straitforward greedy approach is destined to fail...
( scan from first table to last table, take a seat if the table isn't full yet... )
- Fri Dec 10, 2004 4:46 pm
- Forum: Volume 101 (10100-10199)
- Topic: 10131 - Is Bigger Smarter?
- Replies: 93
- Views: 68742
Is this Longest Common Subsequence(LCS) ?
After reading the problem a few times, I thought : Let W be the sequence of elephants sorted by weight in increasing order. Let I be the sequence of elephants sorted by IQ in decreasing order. The solution is the LCS of W and I. If the above is correct, then the implementation would be straitforward...
- Thu Dec 02, 2004 3:53 pm
- Forum: Volume 101 (10100-10199)
- Topic: 10137 - The Trip
- Replies: 159
- Views: 51022
I found something ...
I once take the inputs in this way: scanf("%d",&n); /* n */ scanf("%Lf",&x); /* money */ .... ==> WA now: scanf("%d\n",&n); scanf("%Lf\n",&x); ..... ==> Accepted... Everything else are exactly the same, only the CR characters in the format stri...
- Thu Nov 11, 2004 3:01 pm
- Forum: Volume 2 (200-299)
- Topic: 218 - Moth Eradication
- Replies: 60
- Views: 12128
218-Moth Eradication - Some tricky cases?
#include <stack> #include <stdio.h> #include <stdlib.h> #include <math.h> typedef struct { float x; float y; float theta; }point; int compare( const void *arg1, const void *arg2 ); int cw( point *p1, point *p2, point *p ); float theta( point *p1, point *p2 ); float fabs( float x ); int graham( void...
- Mon Oct 18, 2004 3:57 pm
- Forum: Volume 102 (10200-10299)
- Topic: 10205 - Stack 'em Up
- Replies: 60
- Views: 24659
I got WA,too
[code][c] #include <stdio.h> char n_club[] = "Clubs"; char n_diamond[] = "Diamonds"; char n_heart[] = "Hearts"; char n_spade[] = "Spades"; char *suit_names[4] = { n_club, n_diamond, n_heart, n_spade }; char n_2[] = "2"; char n_3[] = "3"; ch...