讨论 / 水题——删数问题
Marx2002 2016-08-04 05:57:41
点我顶贴 收藏 删除
var s,p,q:ansistring;

k,i,j,n:longint;

begin

readln(s);

readln(k);

n:=length(s);

for i:=1 to k do

begin

p:='';

for j:=1 to n-1 do

p:=p+':';

for j:=1 to n do

begin

q:=s;

delete(s,j,1);

if s<p then p:=s;

s:=q;

end;

s:=p;

dec(n);

end;

for i:=1 to length(s)-1 do

if s[i]<>'0' then break;

for j:=1 to i-1 do

delete(s,1,1);

write(s);

end.

#1 Marx2002@2016-08-04 05:58:12
回复 删除
穷举就可以了

数据又不大

#2 Marx2002@2016-08-04 06:00:56
回复 删除
刚才的程序有漏洞

1000000

1

就不行

改了一下

var s,p,q:ansistring;

k,i,j,n:longint;

begin

readln(s);

readln(k);

n:=length(s);

for i:=1 to k do

begin

p:='';

for j:=1 to n-1 do

p:=p+':';

for j:=1 to n do

begin

q:=s;

delete(s,j,1);

if s<p then p:=s;

s:=q;

end;

s:=p;

dec(n);

end;

for i:=1 to length(s) do

if s[i]<>'0' then break;

for j:=1 to i-1 do

delete(s,1,1);

write(s);

end.

查看更多回复
提交回复