摘要: 1 #include 2 #define MAX 100000 3 4 //数组c为树状数组,MAX为数状数组大小 5 int c[MAX]; 6 7 //lowbit函数 8 int lowbit(int x) 9 {10 return x&(-x);11 }12 13 //树状数组求和函数,求c[1]+c[2]+…+c[x]14 //注意如果题目中可能出现x=0的情况,这里会出现死循环而TLE,改进方法是将原数据全部+115 int sum(int x)16 {17 int ret=0;18 19 while(x>0)20 {21 re... 阅读全文
posted @ 2014-02-06 21:31 ~~Snail~~ 阅读(171) 评论(0) 推荐(0)
摘要: N(3N20000)ping pong players live along a west-east street(consider the street as a line segment). Each player has a unique skill rank. To improve their skill rank, they often compete with each other. If two players want to compete, they must choose a referee among other ping pong players and hold th 阅读全文
posted @ 2014-02-06 21:20 ~~Snail~~ 阅读(236) 评论(0) 推荐(0)