比赛 暑假培训一 评测结果 AATWTWWWWA
题目名称 字符串的展开 最终得分 30
用户昵称 bly1991 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-17 11:34:36
显示代码纯文本
program bly(input,output);
const
  a=['a'..'z'];
  b=['0'..'9'];
var
  s,st,st0:string;
  x,y:char;
  p:boolean;
  i,j,l:integer;
  f1,f2:text;
  p1,p2,p3,z,k,m:integer;
begin
  assign(f1,'expand.in');
  reset(f1);
  readln(f1,p1,p2,p3);
  readln(f1,s);
  close(f1);

  repeat
  p:=false;
  st:='';
    for i:=1 to length(s) do begin
      if (s[i]='-')and(p=false) then begin
      x:=s[i-1]; y:=s[i+1]; m:=i;
      p:=true;
      end;
    end;
    if ord(x)=ord(y)+1 then delete(s,z,1);
    if ord(x)>=ord(y) then l:=l+1;
    if ((x in a)and(y in a))or((x in b)and(y in b)) then begin
     if (ord(x)<ord(y))and(p3<>2) then begin
       delete(s,m,1);
        for i:=ord(x)+1 to ord(y)-1 do begin
          st0:='';
          if (p1=1)and(x in a)and(y in a) then st0:=st0+chr(i);
          if (p1=2)and(x in a)and(y in a) then st0:=st0+chr(i+ord('A')-ord('a'));
          if p1=3 then st:=st+'*';
          if (x in b)and(y in b)and(p1<>3) then st0:=st0+chr(i);
          k:=1;
          while k<p2 do begin
            st0:=st0+st0;
            st:=st+st0;
            k:=k+1;
          end;
        end;
     end;
     if (ord(x)<ord(y))and(p3=2) then begin
       delete(s,m,1);
       for i:=ord(x)+1 to ord(y)-1 do begin
         st0:='';
         if (p1=1)and(x in a)and(y in a) then st0:=st0+chr(i);
         if (p1=2)and(x in a)and(y in a) then st0:=st0+chr(i+ord('A')-ord('a'));
         if p1=3 then st:=st+'*';
         if (x in b)and(y in b)and(p1<>3) then st0:=st0+chr(i);
         k:=1;
         while k<p2 do begin
           st0:=st0+st0;
           st:=st+st0;
           k:=k+1;
         end;
       end;
     end;
    end;
    k:=1;
    insert(st,s,m);
  until pos('-',s)=l;
  assign(f2,'expand.out');
  rewrite(f2);
  writeln(f2,s);
  close(f2);
end.