题解 P1244 【青蛙过河】

其实此题远不用那么麻烦

思路楼下已经说过,我这里就是提供一些写得更短的代码

Pascal

1
2
3
4
5
6
var
h,k:integer;
begin
read(h,k);
writeln(1 shl h*(k+1));
end.

C++

1
2
3
4
5
6
7
8
9
10
#include<cstdio>
using namespace std;
int h,k;
int main(){
scanf("%d%d",&h,&k);
int t=2*k+2;
for(int i=1;i<=h;i++)t*=2;
printf("%d",t/2);
return 0;
}