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:TLe了 递推写的 哪里还可以优化吗?In Reply To:TLe了 递推写的 哪里还可以优化吗? Posted by:___A___ at 2009-06-10 15:34:21 int Dis(const int pos_1,const int pos_2) { int result=0,ptr=1; for (int i=pos_1;i<=pos_2;i++) { result+=value[i]*ptr; ptr++; } return result; } 这个其实是多余的,如果用数组[][]预处理保存数值,可以做到O(1)的查询复杂度 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator