the O(n^4) algorithm can get AC actually !
but need some tips
sort array first
for( d = N to 1 ) //from higher to lower
for( a = 1 to N )
for( b = a+1 to N )
for( c = b+1 to N )
//do comparison here ..
the tip is put the loop d outside, and from higher to lower
it's very efficeint ...
Search found 2 matches
- Thu Mar 18, 2010 3:18 am
- Forum: Volume 101 (10100-10199)
- Topic: 10125 - Sumsets
- Replies: 50
- Views: 24046
- Sat Nov 22, 2008 11:16 am
- Forum: Volume 107 (10700-10799)
- Topic: 10751 - Chessboard
- Replies: 21
- Views: 17503
Re: 10751 - Chessboard
notice 2 things
1. print "4" digit after demical point
2. "blank line" : print blank line "between" every output case.
sample output code
for(int i=0;i<times;++i){
//calculate the path length
printf ("%.4f\n", path_length);
if( i != times-1) printf("\n"); //dont print \n after the last case ...
1. print "4" digit after demical point
2. "blank line" : print blank line "between" every output case.
sample output code
for(int i=0;i<times;++i){
//calculate the path length
printf ("%.4f\n", path_length);
if( i != times-1) printf("\n"); //dont print \n after the last case ...