add: 230329-CN

This commit is contained in:
Eatswap 2023-03-29 16:50:55 +08:00
parent 7b1e933924
commit e057d343a7
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
2 changed files with 40 additions and 1 deletions

39
cpp/2303/230329-CN.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <iostream>
class SolutionCalc {
private:
static constexpr inline int CI(int n, int x) {
if (n <= 1)
return 1;
int ret = 0;
for (int i = 1; i <= x; ++i)
ret += CI(n - 1, i);
return ret;
}
public:
static constexpr inline int countVowelStrings(int n) {
return CI(n, 1) + CI(n, 2) + CI(n, 3) + CI(n, 4) + CI(n, 5);
}
};
class Solution {
private:
static constexpr inline int ANS[] = {
5, 15, 35, 70, 126, 210, 330, 495, 715, 1001, 1365, 1820, 2380, 3060, 3876, 4845, 5985, 7315, 8855, 10626, 12650, 14950,
17550, 20475, 23751, 27405, 31465, 35960, 40920, 46376, 52360, 58905, 66045, 73815, 82251, 91390, 101270, 111930, 123410, 135751,
148995, 163185, 178365, 194580, 211876, 230300, 249900, 270725, 292825, 316251,
};
public:
static constexpr inline int countVowelStrings(int n) {
return ANS[n - 1];
}
};
int main() {
for (int i = 1; i <= 50; ++i)
std::cout << SolutionCalc::countVowelStrings(i) << ", ";
return 0;
}

View File

@ -3,4 +3,4 @@ PROJECT(2303)
SET(CMAKE_CXX_STANDARD 23)
ADD_EXECUTABLE(2303 230328.cpp)
ADD_EXECUTABLE(2303 230329-CN.cpp)