Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:算逆序数可以O(n)完成的In Reply To:算逆序数可以O(n)完成的 Posted by:nightelf at 2007-08-28 12:35:42 > int count_inver(char *str, int len) > { > int i; > int cnt = 0; > int a[4] = {0}; > for(i = len - 1; i >= 0; i--) { > switch (str[i]) { > case 'A': > a[1]++; > a[2]++; > a[3]++; > break; > case 'C': > a[2]++; > a[3]++; > cnt += a[1]; > break; > case 'G': > a[3]++; > cnt += a[2]; > break; > case 'T': > cnt += a[3]; > } > } > return cnt; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator