add: 220222 [cpp]
This commit is contained in:
parent
c8960f3096
commit
ca1327b9dc
|
|
@ -1,6 +1,16 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#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 {
|
class Solution {
|
||||||
private:
|
private:
|
||||||
inline static const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
|
inline static const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -3,4 +3,4 @@ PROJECT(2202)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 23)
|
SET(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
ADD_EXECUTABLE(2202 220222-CN.cpp)
|
ADD_EXECUTABLE(2202 220222.cpp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue