ac1158.pas
来自「同济大学 Online在线题库 AC源代码合集 程序设计竞赛必看资料」· PAS 代码 · 共 38 行
PAS
38 行
program tju1158;
const
maxn=100000;
var
count:array[0..maxn]of byte;
last:array[1..maxn]of word;
n,i:longint;
procedure back(x:longint);
begin
if count[x]=1 then
write(last[x])
else begin
back(x-sqr(last[x]));
write(' ',last[x]);
end;
end;
begin
fillchar(count,sizeof(count),255);count[0]:=0;
for n:=1 to maxn do begin
for i:=1 to trunc(sqrt(n)) do
if count[n-i*i]<count[n] then begin
count[n]:=count[n-i*i];
last[n]:=i;
end;
inc(count[n]);
end;
repeat
read(n);
writeln(count[n]);
repeat
write(last[n]);
dec(n,sqr(last[n]));
if n=0 then writeln else write(' ');
until n=0;
until seekeof;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?