思路:由题意容易得知当只有m片荷叶时,有m+1只青蛙可以过河,增加一个石墩,此时状态为
f[1][m],此时可以过河的青蛙数为2m+2只,石墩上面可以站m+1只,再增加一个石墩的情况下,状态变为f[2][m],这时把原本f[1][m]的状态看做0个石墩,2*m+1片荷叶(至于为什么可以这样做就只能说是数学归纳法了),这时第二个石墩上面可以站2*m+2只青蛙。由此递推下去可以得到下面代码的公式
代码:
#include<iostream>
#include<cstring>
#include <cmath>
#include<algorithm>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N=1e6+10;
int main()
{
int n,m;
cin>>n>>m;
cout<<(m+1)*pow(2,n);
return 0;
}