From ca1327b9dc0edb8d6e45fe75571ef9b23c10cf24 Mon Sep 17 00:00:00 2001 From: Lam Haoyin Date: Tue, 22 Feb 2022 15:49:47 +0800 Subject: [PATCH] add: 220222 [cpp] --- cpp/2202/220222-CN.cpp | 10 ++++++++++ cpp/2202/220222.cpp | 21 +++++++++++++++++++++ cpp/2202/CMakeLists.txt | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 cpp/2202/220222.cpp diff --git a/cpp/2202/220222-CN.cpp b/cpp/2202/220222-CN.cpp index 6c009e6..35cb0ad 100644 --- a/cpp/2202/220222-CN.cpp +++ b/cpp/2202/220222-CN.cpp @@ -1,6 +1,16 @@ #include #include +/** + * 1994. The Number of Good Subsets + * You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers. + * For example, if nums = [1, 2, 3, 4]: + * [2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively. + * [1, 4] and [4] are not good subsets with products 4 = 2*2 and 4 = 2*2 respectively. + * Return the number of different good subsets in nums modulo 109 + 7. + * A subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different. + */ + class Solution { private: inline static const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; diff --git a/cpp/2202/220222.cpp b/cpp/2202/220222.cpp new file mode 100644 index 0000000..d5c6bcc --- /dev/null +++ b/cpp/2202/220222.cpp @@ -0,0 +1,21 @@ +#include +#include + +/** + * 171. Excel Sheet Column Number + * Given a string columnTitle that represents the column title as appear in an Excel sheet, return its corresponding column number. + */ + +class Solution { +public: + static int titleToNumber(const std::string& columnTitle) { + int ret = 0; + for (char ch : columnTitle) + ret = 26 * ret - 'A' + ch + 1; + return ret; + } +}; + +int main() { + return 0; +} diff --git a/cpp/2202/CMakeLists.txt b/cpp/2202/CMakeLists.txt index 541a88c..48623dc 100644 --- a/cpp/2202/CMakeLists.txt +++ b/cpp/2202/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2202) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2202 220222-CN.cpp) +ADD_EXECUTABLE(2202 220222.cpp)