[BOJ] 백준 1551 수열의 변화
출처: https://www.acmicpc.net/problem/1551 Input 5 1 5,6,3,9,-1 Output 1,-3,6,-10 초기 배열에서 원소 변화가 누적되므로 별도 배열 할당 없이 원소값들을 K번 변경합니다. 단, 입/출력시 콤마(,)를 처리해주어야 합니다. 입력 시 출력 시 #include #include #include using namespace std; int N, K; string str, num; int arr[21]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N >> K; cin >> str; istringstream sin(str); int idx = 0; w..
2021. 2. 26.
[BOJ] 백준 1063 킹
출처: https://www.acmicpc.net/problem/1063 Input A1 A2 5 B L LB RB LT Output A1 A2 ① 주어진 명령에 따라 킹의 다음 이동 지점 확인 ② 체스판을 벗어나는지 확인 → 벗어난다면 해당 명령 무시 ③ 돌맹이가 있는지 확인 → 돌맹이가 존재한다면 돌맹이를 킹과 같은 방향으로 이동 가능한지 확인 → 돌맹이가 체스판을 벗어나는 경우 해당 명령어 무시 #include #include #include #include using namespace std; string dir[] = { "R", "L", "B", "T", "RT", "LT", "RB", "LB"}; int dx[] = {0, 0, -1, 1, 1, 1, -1, -1}; int dy[] = {1..
2021. 2. 26.