| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- back propagation
- 너비 우선 탐색
- lazy propagation
- 회고록
- 다익스트라
- 우선 순위 큐
- DP
- 문자열
- 2023
- dropout
- 미래는_현재와_과거로
- NEXT
- c++
- 플로이드 와샬
- BFS
- dfs
- object detection
- 백트래킹
- 알고리즘
- 크루스칼
- 가끔은 말로
- tensorflow
- 세그먼트 트리
- 가끔은_말로
- 이분 탐색
- Overfitting
- 조합론
- pytorch
- 분할 정복
- 자바스크립트
Archives
- Today
- Total
Doby's Lab
백준 12813번: 이진수 연산 (C++) 본문
https://www.acmicpc.net/problem/12813
12813번: 이진수 연산
총 100,000 비트로 이루어진 이진수 A와 B가 주어진다. 이때, A & B, A | B, A ^ B, ~A, ~B를 한 값을 출력하는 프로그램을 작성하시오.
www.acmicpc.net
Solved By: Implementation, Bitwise Operation
비트 연산(Bitwise Operation)을 이해하기 위해 풀어본 문제였습니다.
#include <iostream>
using namespace std;
string a, b;
int main(){
cin >> a >> b;
// AND
for(int i = 0; i < a.length(); i++){
if(a[i] == '1' && b[i] == '1'){
cout << 1;
}
else cout << 0;
}
cout << '\n';
// OR
for(int i = 0; i < a.length(); i++){
if(a[i] == '1' || b[i] == '1'){
cout << 1;
}
else cout << 0;
}
cout << '\n';
// XOR
for(int i = 0; i < a.length(); i++){
if(a[i] != b[i]){
cout << 1;
}
else cout << 0;
}
cout << '\n';
// NOT a
for(int i = 0; i < a.length(); i++){
if(a[i] == '1'){
cout << 0;
}
else cout << 1;
}
cout << '\n';
// NOT b
for(int i = 0; i < a.length(); i++){
if(b[i] == '1'){
cout << 0;
}
else cout << 1;
}
cout << '\n';
return 0;
}'PS > BOJ' 카테고리의 다른 글
| 백준 11280번: 2-SAT - 3 (C++) (0) | 2022.04.27 |
|---|---|
| 백준 20504번: I번은 쉬운 문제 (C++) (1) | 2022.04.26 |
| 백준 11378번: 열혈강호 4 (C++) (0) | 2022.04.25 |
| 백준 18133번: 가톨릭대학교에 워터 슬라이드를? (C++) (0) | 2022.04.24 |
| 백준 1258번: 문제 할당 (C++) (0) | 2022.04.24 |
