| ||||||||||
| 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 | |||||||||
树状数组高级应用啊 sumseek函数 今天才知道!int sumseek (int k)//寻找部分和为k的第一个位置
{
int ans = 0, sum = 0, i;
for (i = 18; i >= 0; i--)
{
ans += (1 << i);
if (ans >= n || sum + bit[ans] >= k) ans -= (1 << i);
else sum += bit[ans];
}
return ans + 1;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator