没事干我就爱吃包子吧 关注:66贴子:8,868

未完结代码

只看楼主收藏回复



IP属地:北京1楼2011-05-21 13:11回复
    var
    s:array[1..2000] of char;
    c:char;
    i,j,m,k,qi,n:longint;
    function qu(ch:char):boolean;
    begin
    qu:=false;
    if (ch in ['a'..'z']) or (ch in ['A'..'Z']) then exit(true);
    end;
    function ou(c:integer):longint;
    var
    l,r,p:integer;
    begin
    p:=0;
    l:=c-1; r:=c;
    repeat
    while (not qu(s[l])) and (l>0) do dec(l);
    while (not qu(s[r])) and (r<m) do inc(r);
    if (s[l]=s[r]) or (ord(s[l])-32=ord(s[r])) or (ord(s[l])+32=ord(s[r])) then begin
    p:=p+2; inc(r); dec(l); end
    else exit(p);
    until (l<1) or (r>m);
    ou:=p;
    end;
    function ji(c:integer):longint;
    var
    l,r,q:integer;
    begin
    q:=1;
    l:=c-1;r:=c+1;
    repeat
    while (l>0) and (not qu(s[l])) do dec(l);
    while (not qu(s[r])) and (r<m) do inc(r);
    if (s[l]=s[r]) or (ord(s[l])-32=ord(s[r])) or (ord(s[l])+32=ord(s[r])) then begin
    q:=q+2; inc(r); dec(l); end
    else exit(q);
    until (l<1) or (r>m);
    ji:=q;
    end;
    begin
    m:=1;
    while not eoln do begin read(c); s[m]:=c; inc(m); end; m:=m-1;
    for i:=2 to m do begin
    if qu(s[i]) then begin j:=ou(i);
                            if j>k then begin k:=j; qi:=i; end;
                            j:=ji(i);
                            if j>k then begin k:=j; qi:=i; end;
                            end;
                            end;
                            writeln(k,qi);
    end.
    


    3楼2011-05-23 16:37
    回复
      广告
      立即查看
      var
      s:array[1..2000] of char;
      c:char;
      i,j,m,k,qi,n:longint;
      function qu(ch:char):boolean;
      begin
      qu:=false;
      if (ch in ['a'..'z']) or (ch in ['A'..'Z']) then exit(true);
      end;
      function ou(c:integer):longint;
      var
      l,r,p:integer;
      begin
      p:=0;
      l:=c-1; r:=c;
      repeat
      while (not qu(s[l])) and (l>0) do dec(l);
      while (not qu(s[r])) and (r<m) do inc(r);
      if (s[l]=s[r]) or (ord(s[l])-32=ord(s[r])) or (ord(s[l])+32=ord(s[r])) then begin
      p:=p+2; inc(r); dec(l); end
      else exit(p);
      until (l<1) or (r>m);
      ou:=p;
      end;
      function ji(c:integer):longint;
      var
      l,r,q:integer;
      begin
      q:=1;
      l:=c-1;r:=c+1;
      repeat
      while (l>0) and (not qu(s[l])) do dec(l);
      while (not qu(s[r])) and (r<m) do inc(r);
      if (s[l]=s[r]) or (ord(s[l])-32=ord(s[r])) or (ord(s[l])+32=ord(s[r])) then begin
      q:=q+2; inc(r); dec(l); end
      else exit(q);
      until (l<1) or (r>m);
      ji:=q;
      end;
      begin
      m:=1;
      while not eoln do begin read(c); s[m]:=c; inc(m); end; m:=m-1;
      for i:=2 to m do begin
      if qu(s[i]) then begin j:=ou(i);
                               if j>k then begin k:=j; qi:=i; end;
                               j:=ji(i);
                               if j>k then begin k:=j; qi:=i; end;
                               end;
                               end;
                               writeln(k,qi);
      end.
      


      IP属地:北京4楼2011-05-23 21:34
      回复

        var
        used:array [0..9] of boolean;
        n,i,j,k,x,a,b:longint;
        function jiancha(x:integer):boolean;
        var
        a:array[1..4] of integer;
        i,j:integer;
        begin
        i:=0;
        jiancha:=true;
        while x<>0 do
        begin
        inc(i);
        a[i]:=x mod 10;
        x:=x div 10;
        end;
        for j:=1 to i do if used[a[j]]=false then exit(false);
        end;
        begin
        readln(n);
        k:=0;
        fillchar(used,sizeof(used),false);
        for i:=1 to n do begin read(x); used[x]:=true; end;
        for i:=100 to 999 do if jiancha(i) then begin
           for j:=10 to 99 do if jiancha(j) then begin
             a:=j mod 10;
             b:=j div 10;
             if (a*i<1000) and (b*i<1000) and (j*i<10000)   then   begin
             if (jiancha(a*i)) and (jiancha(b*i)) and (jiancha(i*j)) then begin
               inc(k);
                end;
                end;
                end;
                end;
        writeln(k);
        end.
        


        5楼2011-05-24 15:42
        回复
          var
          n,m,i,j,k:integer;
          a;array[1..100000] of integer;
          var
          i:integer;
          a:array[1..10] of integer;
          array[1..100,1..100] of integer;
          procedure kuai(l,r:integer);
          var
          x,i,j,y:integer;
          begin
          i:=l; j:=r;
          x:=a[(l+r) div 2];
          repeat
          while a[i]<x do inc(i);
          while a[j]>x do dec(j);
          if i<=j then begin
          y:=a[i];
          a[i]:=a[j];
          a[j]:=y;
          inc(i); dec(j);
          end;
          until i>j;
          if i<r then kuai(i,r);
          if j>l then kuai(l,j);
          end;
          begin
          for i:=1 to 10 do read(a[i]);
          kuai(1,10);
          for i:=1 to 10 do write(a[i],' ');
          end.
          function you(x,i:integer);
          var j:integer;
          begin
          you:=false;
          for j:=i to k do if a[j]=x then exit(true);
          end;
          procedure so(x,y:integer);
          var
          i,j,o,d:integer;
          begin
          d:=a[y]-a[x];
          for i:=x do k do sososoossosoos
          for i:=1 to k do if a[i]=y
          begin
          readln(n,m);
          k:=1;
          for i:=1 to m do
          for j:=i to m do
             begin
             a[k]:=i*i+j*j;
             inc(k);
             end;
          kuai(1,k);
          


          IP属地:北京6楼2011-05-26 16:33
          回复
            var
            n,m:longint;
            g:array[1..100,1..100] of integer;
            i,j,k:integer;
            jian:array[1..100,0..1] of double;
            procedure dj;
            var
            i,j,p1,p2:integer;
            nmin:double;
            min:array[1..100,0..1] of double;
            vis:array[1..100,0..1] of boolean;
            begin
            fillchar(vis,sizeof(vis),false);
            vis[1,0]:=true;
            vis[1,1]:=true;
            for i:=2 to n do begin
            if g[1,i]<>-1 then begin
            jian[i,0]:=g[1,i];
            jian[i,1]:=g[1,i]/2;
            end
            else begin
            jian[i,0]:=1e10;
            jian[i,1]:=1e10;
            end;
            end;
            while vis[n,1]=false do begin
            nmin:=1e10;
            for i:=0 to 1 do
               for j:=1 to n do begin
                if not vis[j,i] and (min[j,i]<nmin) then begin
                 nmin:=min[j,i];
                 p1:=i;
                 p2:=j;
                 end;
                 end;
            vis[p2,p1]:=true;
            jian[p2,p1]:=nmin;
            if p1=0 then begin
            for i:=1 to n do
               if not vis[i,0] and (min[i,0]>min[p2,0]+g[p2,i])and(g[p2,i]<>-1) then begin
               min[i,0]:=min[p2,0]+g[p2,i];
               end;
               for i:=1 to n do
               if not vis[i,1] and (min[i,1]>min[p2,0]+g[p2,i]/2)and(g[p2,i]<>-1) then begin
               min[i,1]:=min[p2,0]+g[p2,i]/2;
               end;
               end
            else begin
               for i:=1 to n do
               if not vis[i,1] and (min[i,1]>min[p2,1]+g[p2,i])and(g[p2,i]<>-1) then begin
               min[i,1]:=min[p2,1]+g[p2,i];
               end;
               end;
            end;
            end;
            begin
            readln(n);
            fillchar(g,sizeof(g),0);
            for i:=1 to n do
            for j:=1 to n do begin
               read(k);
               if (k=0) or (k=-1) then begin g[i,j]:=-1; g[j,i]:=-1; end
               else begin g[i,j]:=k; g[j,i]:=k; end;
               end;
               dj;
            writeln(jian[n,1]:0:1);
            end.
            


            IP属地:北京7楼2011-05-26 21:38
            回复
              {
              ID: llxchad1
              PROG: ariprog
              LANG: PASCAL
              }
              var
              n,m,i,j,k,o,jl:longint;
              a:array[1..500000] of longint;
              da:array[0..100000,1..2] of longint;
              procedure kuai(l,r:longint);
              var
              x,i,j,y:longint;
              begin
              i:=l; j:=r;
              x:=a[(l+r) div 2];
              repeat
              while a[i]<x do inc(i);
              while a[j]>x do dec(j);
              if i<=j then begin
              y:=a[i];
              a[i]:=a[j];
              a[j]:=y;
              inc(i); dec(j);
              end;
              until i>j;
              if i<r then kuai(i,r);
              if j>l then kuai(l,j);
              end;
              procedure sort;
              var
                   falg:boolean;
                   t,p,i,j:longint;
              begin
              for i:=1 to o-1 do
              begin
                  falg:=true;
                  for j:=o-1 downto 1 do
                     begin
                      if da[j,2]>da[j+1,2] then begin
                         falg:=false;
                         t:=da[j,1];
                         p:=da[j,2];
                         da[j,1]:=da[j+1,1];
                         da[j,2]:=da[j+1,2];
                         da[j+1,1]:=t;
                         da[j+1,2]:=p;
                         end;
                     end;{for j}
                  if falg then exit;
              end;{for i}
              end;{procedure}
              function you(jl,sx:longint):boolean;
              var
              i:integer;
              begin
              you:=false;
              for i:=jl to k do if a[i]=sx then begin jl:=i; exit(true); end;
              end;
              function dc(sx,gc:longint):boolean;
              var
              i,gs:longint;
              begin
              dc:=true;
              gs:=2;
              sx:=sx+gc;
              jl:=j;
              while (gs<n)    do begin
              sx:=sx+gc;
              if sx>a[k] then exit(false);
              if you(jl,sx) then inc(gs)
              else exit(false);
              end;
              end;
              begin
              {assign(input,'ariprog.in');   reset(input);
                 assign(output,'ariprog.out');   rewrite(output);   }
              readln(n,m);
              k:=0;
              fillchar(a,sizeof(a),0);
              for i:=0 to m do
              for j:=i to m do begin
              inc(k);
              a[k]:=i*i+j*j;
              end;
              kuai(1,k);
              for i:=2 to k do if (a[i]=a[i-1]) or (a[i]=a[i+1]) then a[i]:=999999;
              o:=0;
              for i:=1 to k do
              for j:=i+1 to k do
              if (dc(a[i],a[j]-a[i])) and (a[j]-a[i]<>0) then begin inc(o);da[o,1]:=a[i];da[o,2]:=a[j]-a[i]; end;
              sort;
              if o=0 then writeln('NONE');
              for i:=1 to o do writeln(da[i,1],' ',da[i,2]);
              close(input);   close(output);
              end.
              


              IP属地:北京8楼2011-05-30 15:40
              回复
                {
                ID: llxchad1
                PROG: ariprog
                LANG: PASCAL
                }
                var
                n,m,i,j,k,o,jl:longint;
                a:array[1..500000] of longint;
                da:array[0..100000,1..2] of longint;
                procedure kuai(l,r:longint);
                var
                x,i,j,y:longint;
                begin
                i:=l; j:=r;
                x:=a[(l+r) div 2];
                repeat
                while a[i]<x do inc(i);
                while a[j]>x do dec(j);
                if i<=j then begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i); dec(j);
                end;
                until i>j;
                if i<r then kuai(i,r);
                if j>l then kuai(l,j);
                end;
                procedure sort;
                var
                     falg:boolean;
                     t,p,i,j:longint;
                begin
                for i:=1 to o-1 do
                begin
                    falg:=true;
                    for j:=o-1 downto 1 do
                       begin
                        if da[j,2]>da[j+1,2] then begin
                           falg:=false;
                           t:=da[j,1];
                           p:=da[j,2];
                           da[j,1]:=da[j+1,1];
                           da[j,2]:=da[j+1,2];
                           da[j+1,1]:=t;
                           da[j+1,2]:=p;
                           end;
                       end;{for j}
                    if falg then exit;
                end;{for i}
                end;{procedure}
                function you(jl,sx:longint):boolean;
                var
                i:integer;
                begin
                you:=false;
                for i:=jl to k do if a[i]=sx then begin jl:=i; exit(true); end;
                end;
                function dc(sx,gc:longint):boolean;
                var
                i,gs:longint;
                begin
                dc:=true;
                gs:=2;
                sx:=sx+gc;
                jl:=j;
                while (gs<n)    do begin
                sx:=sx+gc;
                if you(jl,sx) then inc(gs)
                else exit(false);
                end;
                end;
                begin
                {assign(input,'ariprog.in');   reset(input);
                   assign(output,'ariprog.out');   rewrite(output);}
                readln(n,m);
                k:=0;
                fillchar(a,sizeof(a),0);
                for i:=0 to m do
                for j:=i to m do begin
                inc(k);
                a[k]:=i*i+j*j;
                end;
                kuai(1,k);
                for i:=2 to k do if (a[i]=a[i-1]) or (a[i]=a[i+1]) then a[i]:=-1;
                o:=0;
                for i:=1 to k do
                for j:=i+1 to k do begin
                if (a[i]+(n-1)*(a[j]-a[i])>a[k]) then break;
                if (dc(a[i],a[j]-a[i])) and (a[j]-a[i]<>0) then begin inc(o);da[o,1]:=a[i];da[o,2]:=a[j]-a[i]; end;
                end;
                sort;
                if o=0 then writeln('NONE');
                for i:=1 to o do writeln(da[i,1],' ',da[i,2]);
                close(input);   close(output);
                end.
                


                IP属地:北京9楼2011-05-30 16:21
                回复
                  广告
                  立即查看
                  var
                     exist:array[0..125000] of boolean;
                     base:array[0..40000] of longint;
                     i,j,len,d,tail,next,m,n,ansn:longint;flag:boolean;
                     ans:array[1..10000,1..2] of longint;
                  procedure swap(var x,y:longint);
                  var temp:longint;
                  begin temp:=x;x:=y;y:=temp; end;
                  procedure qsort(l,r:longint);
                  var
                     i,j,x,y:longint;
                  begin
                     i:=l;j:=r;y:=random(r-l)+l;x:=ans[y,2];y:=ans[y,1];
                     while i<=j do
                       begin
                         while (ans[i,2]<x) or ((ans[i,2]=x) and (ans[i,1]<y)) do inc(i);
                         while (ans[j,2]>x) or ((ans[j,2]=x) and (ans[j,1]>y)) do dec(j);
                         if i<=j then
                           begin
                             swap(ans[i,1],ans[j,1]);swap(ans[i,2],ans[j,2]);
                             inc(i);dec(j);
                           end;
                       end;
                     if l<j then qsort(l,j);
                     if i<r then qsort(i,r);
                  end;
                  begin
                    
                     readln(n);readln(m);ansn:=0;fillchar(ans,sizeof(ans),0);
                     fillchar(exist,sizeof(exist),0);fillchar(base,sizeof(base),0);
                     for i:=0 to m do
                       for j:=i to m do
                         exist[sqr(i)+sqr(j)]:=true;
                     for i:=(sqr(m) shl 1) downto 0 do
                       if exist[i] then
                         begin
                           inc(base[0]);base[base[0]]:=i;
                         end;
                     for i:=1 to base[0]-1 do
                       for j:=i+1 to base[0] do
                         begin
                           tail:=base[i];d:=base[i]-base[j];next:=base[j];len:=1;flag:=true;
                           if base[i]-(n-1)*d<0 then break;
                           while (next>=0) and exist[next] and flag do
                             begin
                               inc(len);
                               if len=n then
                                 begin
                                   flag:=false;
                                   inc(ansn);
                                   ans[ansn,1]:=next;
                                   ans[ansn,2]:=d;
                                 end;
                               dec(next,d);
                             end;
                         end;
                     if ansn=0 then
                       writeln('NONE')
                     else
                       begin
                         qsort(1,ansn);
                         for i:=1 to ansn do
                           writeln(ans[i,1],' ',ans[i,2]);
                       end;
                    
                  end.


                  IP属地:北京10楼2011-05-30 21:21
                  回复
                    var
                       f:array[0..20,0..20,0..20]of boolean;
                       af,bf,cf,a,b,c:byte;
                    procedure pp(var d,e,ef:byte);
                    forward;
                    procedure ss;
                    begin
                       if f[a,b,c] then exit;
                       f[a,b,c]:=true;
                       pp(a,b,bf);
                       pp(a,c,cf);
                       pp(b,a,af);
                       pp(b,c,cf);
                       pp(c,a,af);
                       pp(c,b,bf);
                    end;
                    procedure pp(var d,e,ef:byte);
                    var dd,ee:byte;
                    begin
                       dd:=d;ee:=e;
                       if d>ef-e then begin
                         d:=d-ef+e;
                         e:=ef;
                         ss;d:=dd;e:=ee;
                         exit
                       end;
                       e:=e+d;d:=0;ss;d:=dd;e:=ee;
                    end;
                    begin
                         readln(af,bf,cf);c:=cf;
                       ss;
                       for af:=0 to cf do
                         if f[0,cf-af,af] then
                           write(af,' ');
                    end.


                    IP属地:北京11楼2011-05-31 14:47
                    回复

                      var
                      a,b,c:array[-30..30] of boolean;
                      da:array[1..30] of longint;
                      i,j,k,n,o:longint;
                      procedure print;
                      begin
                      for i:=1 to n-1 do write(da[i],' ');
                      write(da[n]);
                      writeln;
                      end;
                      procedure try(x:integer);
                      var
                      i,j:longint;
                      begin
                      for i:=1 to n do
                      if (not a[i]) and (not b[i-x]) and (not c[i+x]) then begin
                      a[i]:=true;
                      b[i-x]:=true;
                      c[i+x]:=true;
                      da[x]:=i;
                      if x=n then begin inc(o); if o<=3 then print; k:=k+1; end
                      else try(x+1);
                      a[i]:=false;
                      b[i-x]:=false;
                      c[i+x]:=false;
                      end;
                      end;
                      begin
                      o:=0; k:=0;
                      for i:=-30 to 30 do begin a[i]:=false; b[i]:=false; c[i]:=false; end;
                      readln(n);
                      try(1);
                      writeln(k);
                      end.
                      


                      IP属地:北京12楼2011-06-01 13:48
                      回复

                        var
                        s:string;
                        i,j,k,n:longint;
                        da:array[1..10000] of longint;
                        function ss(x:longint):boolean;
                        var
                        i,j:longint;
                        begin
                        ss:=true;
                        for i:=2 to trunc(sqrt(x)) do
                        if   x mod i=0 then exit(false);
                        end;
                        procedure soubuqi(x:longint);
                        var
                        i,j,w:longint;
                        begin
                        if x>k then begin writeln(x); exit; end
                        else   begin
                        for i:=1 to 5 do begin
                        w:=x*10+2*i-1;
                        if ss(w) then soubuqi(w);
                        end;
                        end;
                        end;
                        begin
                        readln(n);
                        k:=1;
                        for i:=1 to n-1 do   k:=k*10;
                        soubuqi(2);
                        soubuqi(3);
                        soubuqi(5);
                        soubuqi(7);
                        end.
                        


                        IP属地:北京13楼2011-06-01 13:48
                        回复
                          哦哈哈哈哈 第一章通关


                          IP属地:北京14楼2011-06-01 13:48
                          回复
                            var
                            a:array[1..500] of string;
                            i,j,k:integer;
                            pro,proin,proout,id,flagqian:string;
                            procedure qian;
                            begin
                            writeln('{');
                            writeln('ID:',id);
                            writeln('PROG:',pro);
                            writeln('LANG:PASCAL');
                            writeln('}');
                            end;
                            begin
                            readln(id);
                            readln(pro);
                            readln(flagqian);
                            proin:=pro; proout:=pro;
                            insert('.in',proin,length(pro)+1);
                            insert('.out',proout,length(pro)+1);
                            assign(input,proin);
                            assign(output,proout);
                            reset(input);
                            rewrite(output);
                            if (flagqian='y') or (flagqian='Y') then qian;
                            k:=1;
                            while not eof do begin
                            readln(a[k]);
                            inc(k);
                            end;
                            for i:=1 to k-3 do writeln(a[i]);
                            writeln('close(input);close(output);');
                            writeln(a[k-1]);
                            close (output);
                            end.
                            


                            15楼2011-06-02 16:27
                            回复
                              广告
                              立即查看
                              var
                              lu,w,t,cost:array[0..1001] of longint;
                              sum,i,j,time,k,n,qs,l,r,now:longint;
                              begin
                              fillchar(lu,sizeof(l),0);
                              fillchar(w,sizeof(w),0);
                              fillchar(t,sizeof(t),0);
                              fillchar(cost,sizeof(cost),0);
                              readln(n);
                              readln(qs);
                              for i:=1 to n do   read(lu[i],w[i]);
                              l:=qs-1; r:=qs+1; now:=qs; time:=0;
                              cost[1]:=w[1]*(lu[qs]-lu[1]);
                              cost[n]:=w[n]*(lu[n]-lu[qs]);
                              if 2<=qs-1 then
                              for i:=2 to qs-1 do
                              cost[i]:=cost[i-1]+w[i]*(lu[qs]-lu[i]);
                              if n-1>=qs+1 then
                              for i:=n-1 downto qs+1 do
                              cost[i]:=cost[i+1]+w[i]*(lu[i]-lu[qs]);
                              while (l>0) and (r<n+1) do begin
                              if cost[r]*(lu[now]-lu[l])<cost[l]*(lu[r]-lu[now]) then
                              begin
                              time:=time+(lu[now]-lu[l]);
                              t[l]:=time;
                              now:=l;
                              l:=l-1;
                              if now=1 then begin
                              for j:=r to n do begin t[j]:=time+lu[j]-lu[1];r:=r+1; end;
                              end;
                              end
                              else begin
                              time:=time+(lu[r]-lu[now]);
                              t[r]:=time;
                              now:=r;
                              r:=r+1;
                              if now=n then begin
                              for k:=l downto 1 do begin t[k]:=time+lu[n]-lu[k]; l:=l-1; end;
                              end;
                              end;
                              end;
                              for i:=1 to n do sum:=sum+t[i]*w[i];
                              writeln(sum);
                              end.
                              


                              IP属地:北京16楼2011-06-02 21:32
                              回复