728x90
https://www.acmicpc.net/problem/11723
#include <string>
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int calculationNum, bit = 0, num; // bit ์ด๊ธฐํ ํ์
string calculationString;
cin >> calculationNum;
for (int i = 0; i < calculationNum; i++) {
cin >> calculationString;
if (calculationString == "add") {
cin >> num;
bit |= (1 << num);
}
else if (calculationString == "remove") {
cin >> num;
bit &= ~(1 << num);
}
else if (calculationString == "check") {
cin >> num;
if (bit & (1 << num)) cout << 1 << "\n";
else cout << 0 << "\n";
}
else if (calculationString == "toggle") {
cin >> num;
bit ^= (1 << num);
}
else if (calculationString == "all") {
bit = (1 << 21) - 1;
}
else if (calculationString == "empty") {
bit = 0;
}
}
return 0;
}
728x90
'๐ Coding Test Study > Algorithm Problem' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++][Beakjoon][DFS/BFS] 13023๋ฒ ABCDE (0) | 2022.05.10 |
---|---|
[C++][Beakjoon] 11724๋ฒ ์ฐ๊ฒฐ์์ (0) | 2022.05.10 |
[C++][Baekjoon] 10971๋ฒ ์ธํ์ ์ํ2 (0) | 2022.05.08 |
[C++][Baekjoon][Math] 6588๋ฒ ๊ณจ๋๋ฐํ์ ์ถ์ธก(feat. C++ ์ ์ถ๋ ฅ ์๊ฐ ๋จ์ถ) (0) | 2022.04.03 |
[C++][Baekjoon][Math] 1978๋ฒ ์์์ฐพ๊ธฐ (0) | 2022.04.03 |