int result() { int longest_cycle_length; int smallest_link_in_longest_cycle; for (int i = 1; i <= MAX_START; i++) { int someCycleLink; int length = chainLength(i, &someCycleLink); if (length > longest_cycle_length) { longest_cycle_length = length; smallest_link_in_longest_cycle = smallestLink(someCycleLink, length); // printf("%d: %d, %d\n", i, length, smallest_link_in_longest_cycle); } } return smallest_link_in_longest_cycle; }
int main(int argc, char* argv[]) { int max_len = -1; long max_ind = -1; std::vector<bool> mark(num+1,true); for ( long i = 1 ; i <= num ; ++ i) { if(!mark[i]) continue; int len = chainLength(i,mark); if(len > max_len) { max_len = len; max_ind = i; } } std::cout<<max_len<<' '<<max_ind<<std::endl; // std::cout<<divSummation(divs)<<std::endl; }
ostream& MSHashTable::printChainLengths(ostream& aStream_) const { for (unsigned i=0;i<size();i++) aStream_<<chainLength(i)<<" "; return aStream_<<endl; }