Fading Coder

One Final Commit for the Last Sprint

Solutions to Problems 1–5 of the 1024 2nd Lanqiao Cup Biweekly Algorithm Contest

Problem 1: Freshman Challenge The answer is a constant value. #include <cstdio> int main() { printf("%d\n", 15); return 0; } Problem 2: Flooring We only need the product of the dimensions to be divisible by 6, and both dimensions must be large enough for a 2×3 or 3×2 tile. #include &...

Solving the Binary Land Problem Using Breadth-First Search

This problem can be effectively solved using a Breadth-First Search (BFS) algoritmh. The core idea is to explore possible states, where a state is defined by the positions of two characters and the number of steps taken to reach that state. We can represent a state using a structure that stores the...

C++ Function Fundamentals for Competitive Programming

Essential C++ Function Concepts When preparing for coding competitions like LeetCode, understanding C++ function mechanics is crucial. This guide covers four fundamental function concepts that frequently appear in competitive programming scenarios. 1. Inline Functions An inline function is declared...

Working with priority_queue in C++

Understanding priority\_queue in C++ The priority\_queue is a crucial container within the C++ Standard Template Library (STL). While it shares some similarities with a standard queue, it differs significantly in behavior: Top-priority element is always at front: The queue organizes its elements bas...

Building a Serial Debug Assistant with Qt (Inspired by Ai-Thinker)

Building a Serial Debug Assistant with Qt (Inspired by Ai-Thinker)
1. Project Overview A serial debug assistant is a tool for serial communication testing. It can open, close, configure serial ports, read and write serial data, and perform other common serial communication operations. It is widely used in embedded system debugging, module testing, communication pro...

Minimum Board Length Calculation Using Greedy Strategy

Problem Analysis The objective is to cover all occupied stalls in a linear arrangement using a maximum of M boards, minimizing the total length of the boards. If only one board is available, it must span from the leftmost occupied stall to the rightmost. Adding more boards allows leaving gaps betwee...

Understanding std::function in C++

std::function is a template class introduced in C++11 that serves as a general-purpose wrapper for callable entities. It allows you to store, copy, and invoke a variety of callable objects using a uniform interface. Callable objects in C++ include: Free functions Lambda expressions Function objects...

Implementing the Decorator Pattern in C++ for Dynamic Function Extension

The Decorator pattern enables adding new responsibilities to an object dynamically without altering its structure. It creates a chain of decorators, each wrapping the previous object, forming a linked structure similar to a linked list. This approach maintains references to original functionality wh...

Core Mechanics and API Usage of C++ std::vector

std::vector implements a dynamically resizable sequence container backed by contiguous memory. This layout enables O(1) random access via indexing, matching raw array performance. Unlike static arrays, vectors manage their own memory footprint, automatically expanding when new elements exceed the cu...

C++ Object-Oriented Programming Fundamentals: Inheritance and Constructors

Experiment Objectives Understand the relationship between classes and objects, master constructors and destructors, and implement encapsulation Learn how to define base and derived classes, and understand the calling order of constructors and destructors Master the principles and methods of multiple...