some programs!!

This commit is contained in:
rogerwang2008 committed 2026-09-28 14:05:06 +08:00
1 parent ed054247d5
commit 71f1022dea
38 files changed
+1037 -281

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#include <iostream>
#include <array>
constexpr int MAX_N = 21;
// 编译期生成斐波那契数列
constexpr std::array<int, MAX_N> make_fib() {
std::array<int, MAX_N> fib{}; // 零初始化
fib[0] = 1;
fib[1] = 1;
for (int i = 2; i < MAX_N; ++i) {
fib[i] = fib[i - 1] + fib[i - 2];
}
return fib;
}
static constexpr auto fib = make_fib();
int x;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> x;
while (std::cin >> x) {
std::cout << fib[x - 1] << std::endl;
}
return 0;
}