📄 ac1159.pas
字号:
program tju1159;
const
maxparts=8;
maxdigits=12;
var
p:array[0..maxparts]of byte;
d:array[1..maxdigits]of byte;
n,count:longint;
procedure search(l,x,d0:byte);
var
i,t,d1:byte;
function check:boolean;
var
pd,pp,x,e,y:word;
begin
pp:=0;x:=0;e:=1;
for pd:=1 to d1 do begin
inc(x,e*d[pd]);
if x*2>p[pp] then begin
dec(x,e*d[pd]);inc(pp);
if x<>p[pp] then begin check:=false;exit;end;
x:=d[pd];e:=1;
y:=pd-1;while d[y]=0 do begin x:=x*10;e:=e*10;dec(y);end;
end;
e:=e*10;
end;
check:=x=p[pp+1];
end;
begin
if x=0 then exit;
for i:=1 to x shr 1 do begin
p[l]:=i;
t:=i;d1:=d0;
repeat
inc(d1);d[d1]:=t mod 10;t:=t div 10;
until t=0;
if check then inc(count);
search(l+1,i,d1);
end;
end;
begin
repeat
read(n);
p[0]:=n;
count:=1;
search(1,n,0);
writeln(count);
until seekeof;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -