mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Update bit.cpp
This commit is contained in:
parent
883d9dc3a4
commit
dba806ca60
@ -6,7 +6,7 @@ using namespace std;
|
|||||||
class Bit
|
class Bit
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
vector < int > bit;
|
vector<int> bit;
|
||||||
inline int offset(int x)
|
inline int offset(int x)
|
||||||
{
|
{
|
||||||
return (x & (-x));
|
return (x & (-x));
|
||||||
@ -14,7 +14,7 @@ class Bit
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Bit(vector < int > & arr)
|
Bit(vector<int>& arr)
|
||||||
{
|
{
|
||||||
n = arr.size();
|
n = arr.size();
|
||||||
bit.assign(n + 1, 0);
|
bit.assign(n + 1, 0);
|
||||||
@ -62,7 +62,7 @@ class Bit
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int n = 5;
|
int n = 5;
|
||||||
vector <int> arr = { 1, 2, 3, 4, 5 };
|
vector<int> arr = { 1, 2, 3, 4, 5 };
|
||||||
Bit x(arr);
|
Bit x(arr);
|
||||||
|
|
||||||
assert(x.sum_range(0, 0) == 1);
|
assert(x.sum_range(0, 0) == 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user