hiho week 317 register

Ended

Participants:32

Verdict:Accepted
Score:100 / 100
Submitted:2020-07-28 07:25:01

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "stdio.h"
int plant[100005]={0};
int bits[100005]={0};
inline int bitcount(int i)
{
    return i&(-i);
    // return i&(i^(i-1));
}
void update(int i, int N)
{
    while(i<=N)
    {
        bits[i]++;
        i+=bitcount(i);
    }
}
int sum(int i)
{
    int s=0;
    while(i>0)
    {
        s+=bits[i];
        i-=bitcount(i);
    }
    return s;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX