#include <iostream> #include <vector> #include <cmath> #include <cstdio> using namespace std; int main(){ int a,b; cin >> a >> b; vector<int> dp(a,0); dp[0] = 1; if(b == 1) cout << b; else{ dp[1] = 2; for(int i = 2; i<a; ++i){ dp[i] = dp[i-1] + dp[i-2]; } long long g = dp[a-1] * b; cout << g; } return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <iostream> #include <vector> #include <cmath> #include <cstdio> using namespace std; int main(){ int a,b; cin >> a >> b; vector<int> dp(a,0); dp[0] = 1; if(b == 1) cout << b; else{ dp[1] = 2; for(int i = 2; i<a; ++i){ dp[i] = dp[i-1] + dp[i-2]; } long long g = dp[a-1] * b; cout << g; } return 0; } |