본문 바로가기

Programming/BOJ

(14)
[C/C++] BOJ #1021 - Rotating Queues The Baekjoon problem #1021 “Rotating Queue” involves using a deque to efficiently extract elements from specific positions. The goal of the problem is to calculate the minimum number of operations required to extract the desired elements in the given order. The term “operation” here refers to either rotating the deque one step to the left, one step to the right, or directly removing the first el..
[C/C++] BOJ #1019 - Book Page Han Ji-min loves books and works at a library.  One spring night, while reading a book, she suddenly became curious about how many digits were written on the pages of the book she was flipping through.  The book’s pages are numbered from page 1 to page N. Let’s calculate how many digits are written on the pages of the book she read.  Although it’s a bit different from the original problem, I was..
[C/C++] BOJ #1018 - Paint Chess Board Again The Baekjoon #1018 - Paint Chess Board Again problem requires you to determine the minimum number of squares that need to be repainted on a given rectangular board so that it becomes a valid 8x8 chessboard.Problem Description:1. Input:• A board of size NxM (where N,M > 8).• Each cell of the board contains either 'W' (white) or 'B' (black).• A chessboard is valid if:• Adjacent cells (both horiz..
[C/C++] BOJ #1017 - Prime pairs The problem “Prime Pairs” requires finding a pair of prime numbers for a given even number  n  such that the sum of the two prime numbers equals  n . This problem is a variation of the famous Goldbach’s conjecture, which states that every even integer greater than 2 can be expressed as the sum of two prime numbers.Problem Description:1. You are given an even number  n  ( \(n \geq 4\) ).2. The ta..
[C/C++] BOJ #1016 Square Nono Number Problem Description:You are given two integers, min and max, which define a range of numbers [min, max]. Your task is to find how many numbers within this range are not divisible by the square of any integer greater than 1. Such numbers are called “non-square-free” numbers.In mathematical terms, a number x in the range [min, max] is considered not square-free if there exists an integer k > 1 suc..
[C/C++] BOJ #1015 Sorting Numbers The problem BOJ #1015 - Sorting Numbers requires the following:You are given an array  A  of size  N . Your task is to create a permutation  P  of length  N  such that:1. Rearranged Order: When the elements of  A  are rearranged according to  P , they form a non-decreasing sequence. Specifically, if  B  is the rearranged array, then  B[i] = A[P[i]]  should hold, and  B  must be sorted in ascendi..
[C/C++] BOJ #1012 organic cabbages There are cabbages planted in your vegetable garden, and you want to grow them organically by releasing cabbage whiteworms. A single cabbage whiteworm is sufficient to prevent pests, as it can move to adjacent cabbages in the cluster.This problem is similar to the “number of islands” problem and other common problems. It can be solved using the basic DFS or BFS algorithms in graph theory. You ca..
[C/C++] BOJ #1011 Fly me to the Alpha Centauri This problem is about finding the minimum number of times a warp drive needs to be activated to travel to Alpha Centauri. Though it sounds like a space exploration problem, it essentially boils down to finding the largest number 'k' where the sum 1+2+3+...+k is less than half the distance to Alpha Centauri.Warping to Alpha CentauriAlpha Centauri is located approximately 4.37 light-years away fro..
[C/C++] #1010 Building bridges(combination) The Baekjoon Problem #1010 “Building Bridges” requires a certain understanding of the concept of combinations in probability and statistics. On one side of the river, there are  N sites, and on the other side, there are  M  sites. The goal is to build bridges connecting the  N  sites on the left side to M  sites on the right side, ensuring that the bridges do not cross each other. The question a..
[C/C++] #1009 Fixing Distributed Processing, Efficient Problem Solving in Distributed Processing: Using Number TheoryWhen it comes to solving distributed processing problems, it is possible to solve them through brute force. However, for more efficient execution, number theory comes into play. The problem itself isn't hard to understand.  Imagine you have N data points, and 10 computers sequentially process each data point one by one. The ..