-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitset.cpp
More file actions
49 lines (38 loc) · 1009 Bytes
/
Bitset.cpp
File metadata and controls
49 lines (38 loc) · 1009 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
void solve() {
// --- Initialization ---
bitset<20> bs1,
bs2(1234),
bs3("10101100");
// --- Capacity ---
// size()
// --- Element accessa ---
// [index], test(index)
// count(), all(), any(), none()
// --- Modifiers ---
// set(), set(index)
// reset(), reset(index)
// flip(), flip(index)
// &, |, ^, <<, >>, ~
// &=, |=, ^=, <<=, >>=
// --- Conversions ---
// to_string()
// to_ulong(), to_ullong()
// --- Hints ---
// _Find_first(), return index of the first set bit.
// _Find_next(index), return index of the next set bit after index.
cout << bs3 << '\n';
cout << bs3._Find_first() << '\n';
cout << bs3._Find_next(1) << ' ' << bs3._Find_next(2) << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}