首页 > 代码库 > 1543: 【基础】印度国王的棋盘
1543: 【基础】印度国王的棋盘
program ex1543;
var n,m,t,w,i:integer;
a,b:array[1..200] of integer;
procedure gjc;
var i:integer;
begin
for i:=1 to t do
a[i]:=a[i]*2;
t:=1;
while a[t]<>0 do
begin
a[t+1]:=a[t+1]+a[t] div 1000;
a[t]:=a[t] mod 1000;
inc(t);
end;
dec(t);
end;
procedure gjj;
var i:integer;
begin
for i:=1 to t do b[i]:=b[i]+a[i];
w:=1;
while b[w]<>0 do
begin
b[w+1]:=b[w+1]+b[w] div 1000;
b[w]:=b[w] mod 1000;
inc(w);
end;
dec(w);
end;
begin
readln(n,m);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
a[1]:=1;t:=1; w:=1;
if n=1 then b[1]:=1;
for i:=1 to m-1 do
begin
gjc;
if i>=n-1 then gjj;
end;
write(b[w]) ;
if w>1 then write(‘,‘);
for i:=w-1 downto 1 do
begin
if b[i]<10 then write(‘00‘);
if (b[i]>=10) and (b[i]<100) then write(‘0‘);
write(b[i]);
if i<>1 then write(‘,‘)
end;
end.
1543: 【基础】印度国王的棋盘