# 问题 A: [贪心算法]删数问题

【输入样例】
175438
4
【输出样例】
13

var
s:string;
i,n,j,k:longint;
begin
i:=1;
for j:= 1 to n do
for i:= 1 to length(s) do
if i=length(s) then
begin
delete(s,i,1);
break;
end else
if s[i]>s[i+1] then
begin
delete(s,i,1);
break;
end;
for i:=1 to length(s) do
begin
if s[i]<>'0' then begin k:=i; break; end;
end;
for i:=k to length(s) do
write(s[i]);
writeln;
end.

var
s:string;
i,n,j,k:longint;
begin
s:=s;
for i:=1 to n do
begin
j:=1;
while (s[j]<=s[j+1])and(j<length(s)) do inc(j);
delete(s,j,1);
end;
for i:=1 to length(s) do
begin
if s[i]<>'0' then begin k:=i; break; end;
end;
for i:=k to length(s) do
write(s[i]);
writeln;
end.

program delet;
var
a:array[1..240]of longint;
st:string;
i,n,s,j,k:longint;
begin
n:=length(st);
for i:= 1 to n do val(st[i],a[i]);
i:=1;
for j:= 1 to s do
while i<=n do
begin
if i=n then
begin
dec(n);
i:=1;
break;
end else
if a[i]>a[i+1] then
begin
for k:= i to n-1 do
a[k]:=a[k+1];
dec(n);
i:=1;
break;
end else inc(i);
end;
for i:= 1 to n do
begin
if a[i]<>0 then begin k:=i; break; end;
end;
for i:= k to n do write(a[i]);
writeln;
end.

• 本文已收录于以下专栏：

举报原因： 您举报文章：问题 A: [贪心算法]删数问题 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)