求助,99分!
查看原帖
求助,99分!
945370
MineCraftLittlePea楼主2024/11/29 21:54
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n,l3 = 1,l2 = 2,l1 = 4,l0;
	cin >> n;
	if (n == 1) {
		cout << 1;
		return 0;
	}
	if (n == 2) {
		cout << 2;
		return 0;
	}
	if (n == 2) {
		cout << 4;
		return 0;
	}
	for (int i = 4; i <= n; i++) {
		l0 = l1 + l2 + l3;
		l3 = l2;
		l2 = l1;
		l1 = l0;
	}
	cout << l0;
	return 0;
}

2024/11/29 21:54
加载中...