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: 14596
- Sun Oct 07, 2007 12:02 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11293 - Tournament
- Replies: 19
- Views: 8523
- Fri Oct 05, 2007 4:37 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11293 - Tournament
- Replies: 19
- Views: 8523
- Fri Oct 05, 2007 4:34 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11294 - Wedding
- Replies: 21
- Views: 11545
- Tue Oct 02, 2007 3:32 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11300 - Spreading the Wealth
- Replies: 14
- Views: 6923
- Tue Oct 02, 2007 7:42 am
- Forum: Volume 113 (11300-11399)
- Topic: 11302 - Hexadecimal Digits of an Integral
- Replies: 10
- Views: 3909
- Mon Oct 01, 2007 3:38 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11302 - Hexadecimal Digits of an Integral
- Replies: 10
- Views: 3909
- Mon Oct 01, 2007 12:02 pm
- Forum: Volume 112 (11200-11299)
- Topic: 11298 - Dissecting a Hexagon
- Replies: 25
- Views: 10723
- Mon Oct 01, 2007 6:13 am
- Forum: Volume 112 (11200-11299)
- Topic: 11298 - Dissecting a Hexagon
- Replies: 25
- Views: 10723
- Sat Sep 29, 2007 2:12 am
- Forum: Volume 107 (10700-10799)
- Topic: 10749 - Automobile Travelling
- Replies: 9
- Views: 6171
- Fri Sep 28, 2007 3:17 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10749 - Automobile Travelling
- Replies: 9
- Views: 6171
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 ...
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 ...
- Wed Sep 26, 2007 5:31 am
- Forum: Volume 112 (11200-11299)
- Topic: 11287 - Pseudoprime Numbers
- Replies: 11
- Views: 7038
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: 13600
- Tue Sep 18, 2007 1:03 am
- Forum: Volume 112 (11200-11299)
- Topic: 11280 - Flying to Fredericton
- Replies: 43
- Views: 23090
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: 13600