add: 220222 [cpp]

This commit is contained in:
Lam Haoyin 2022-02-22 15:49:47 +08:00
parent c8960f3096
commit ca1327b9dc
No known key found for this signature in database
GPG Key ID: 8C089CB1A2B7544F
3 changed files with 32 additions and 1 deletions

View File

@ -1,6 +1,16 @@
#include <vector>
#include <iostream>
/**
* 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};

21
cpp/2202/220222.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <iostream>
#include <string>
/**
* 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;
}

View File

@ -3,4 +3,4 @@ PROJECT(2202)
SET(CMAKE_CXX_STANDARD 23)
ADD_EXECUTABLE(2202 220222-CN.cpp)
ADD_EXECUTABLE(2202 220222.cpp)