You may find this O(n) algorithm interesting (no need to know how many color there are).
http://citeseer.ist.psu.edu/494676.html
Search found 25 matches
- Sun Oct 07, 2007 12:05 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11307 - Alternative Arborescence
- Replies: 22
- Views: 11545
- Sun Oct 07, 2007 12:02 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11293 - Tournament
- Replies: 19
- Views: 7134
- Fri Oct 05, 2007 4:37 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11293 - Tournament
- Replies: 19
- Views: 7134
- Fri Oct 05, 2007 4:34 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11294 - Wedding
- Replies: 21
- Views: 9521
- Tue Oct 02, 2007 3:32 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11300 - Spreading the Wealth
- Replies: 14
- Views: 5978
- Tue Oct 02, 2007 7:42 am
- Forum: Volume 113 (11300-11399)
- Topic: 11302 - Hexadecimal Digits of an Integral
- Replies: 10
- Views: 3083
- Mon Oct 01, 2007 3:38 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11302 - Hexadecimal Digits of an Integral
- Replies: 10
- Views: 3083
- Mon Oct 01, 2007 12:02 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11298 - Dissecting a Hexagon
- Replies: 25
- Views: 9009
- Mon Oct 01, 2007 6:13 am
- Forum: Volume 112 (11200-11299)
- Topic: 11298 - Dissecting a Hexagon
- Replies: 25
- Views: 9009
- Sat Sep 29, 2007 2:12 am
- Forum: Volume 107 (10700-10799)
- Topic: 10749 - Automobile Travelling
- Replies: 9
- Views: 5453
My output has the same number of moves as your output. Could you please check what's wrong with my code : #include <iostream> #define MAXK 1005 #define MAXP 15 #define MAXQ 15 using namespace std; int m,n,k,p,q,x0,y0,k0; bool c[MAXK][MAXK]; int pq[MAXK*(MAXP+1)*(2*MAXQ+1)*3]; int d[MAXK],a[MAXK]; in...
- Fri Sep 28, 2007 3:17 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10749 - Automobile Travelling
- Replies: 9
- Views: 5453
Help me! plz
Could someone give me the output for this input? 20 31 31 9 4 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 ...
- Wed Sep 26, 2007 5:31 am
- Forum: Volume 112 (11200-11299)
- Topic: 11287 - Pseudoprime Numbers
- Replies: 11
- Views: 5398
In the case where n is odd, it should be :
Code: Select all
return (square(BigMod(a, n/2, p))%p)*(a % p) % p;
- Tue Sep 18, 2007 3:43 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11281 - Triangular Pegs in Round Holes
- Replies: 26
- Views: 11678
i change your program to compute the condition for all 3 edges of the triangle and it got AC: bool valid(double a, double b, double c, double d){ double theta, alpha, eta, xx; if( a - d > eps ) return false ; theta = acos( ( a*a + b*b - c*c )/(2*a*b) ) ; alpha = acos( a/d ); // since D[j] = 2*r ; et...
- Tue Sep 18, 2007 1:03 am
- Forum: Volume 112 (11200-11299)
- Topic: 11280 - Flying to Fredericton
- Replies: 43
- Views: 17525
Code: Select all
dp(x,y) = min{dp(x,y), dp(i, y-1)+cost(i,x)};
- Tue Sep 18, 2007 12:57 am
- Forum: Volume 112 (11200-11299)
- Topic: 11281 - Triangular Pegs in Round Holes
- Replies: 26
- Views: 11678
theta = acos( ( a*a + b*b - c*c )/(2*a*b) ) ; alpha = acos( a/D[j] ); // since D[j] = 2*r ; I believe that you have used the wrong angle. I used this one theta = acos( ( a*a + b*b - c*c )/(2*a*b) ) ; alpha = asin(c/D[j] ); if (alpha-theta>-eps) ... And you used it for all 3 edges of the triangle.[/...