#include <iostream> using namespace std; int main() { int n, n_0, n_1, n_2, sum; cin >> n; n_0 = 0; n_1 = 0; n_2 = 1; for (int i = 3; i <= n; ++i){ n_2 = n_2 + n_1; n_1 = n_0; n_0 = n_2; } sum = n_0 + n_1 + n_2; cout << sum << endl; return 0; }
#include <iostream> using namespace std; int main() { int n, n_0, n_1, n_2, sum; cin >> n; n_0 = 0; n_1 = 0; n_2 = 1; for (int i = 3; i <= n; ++i){ n_2 = n_2 + n_1; n_1 = n_0; n_0 = n_2; } sum = n_0 + n_1 + n_2; cout << sum << endl; return 0; }