Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why wrong??用了最原始的方法了

Posted by richardhuang at 2004-05-08 01:18:59 on Problem 1496
program fafd;
var
  s,s1:string;
  c:array [1..1000] of char;
  i,j,k:longint;
  d:array [1..5] of integer;
  ch:char;
begin
  while not eof do
  begin
    readln(s);
    for i:=1 to length(s) do
    begin
      c[i]:=s[i];
    end;
    ch:=' ';
    for i:=1 to length(s)-1 do
    for j:=i+1 to length(s) do
    if (c[i]>=c[j]) then begin
       ch:=c[i];
    end;
    if ch<>' ' then writeln(0)
    else begin
      fillchar(d,sizeof(d),0);
      for i:=1 to length(s) do d[i]:=ord(c[i])-96;
      case length(s) of
      1:writeln(d[i]);
      2:begin
          k:=26;
          for i:=1 to d[1]-1 do
          k:=k+(26-i);
          k:=k+d[2]-d[1];
          writeln(k);
        end;
      3:begin
          k:=13*27;
          for i:=1 to d[1]-1 do
          k:=k+trunc((26-i)*(25-i)/2);
          for i:=d[1]+1 to d[2]-1 do
          k:=k+(26-i);
          k:=k+d[3]-d[2];
          writeln(k);
        end;
      4:begin
          k:=13*27+(26*25*4);
          for i:=1 to d[1]-1 do
          k:=k+trunc((26-i)*(25-i)*(24-i)/6);
          for i:=d[1]+1 to d[2]-1 do
          k:=k+trunc((26-i)*(25-i)/2);
          for i:=d[2]+1 to d[3]-1 do
          k:=k+26-i;
          k:=k+d[4]-d[3];
          writeln(k);
        end;
      5:begin
          k:=13*27+(26*25*4)+(26*25*23);
          for i:=1 to d[1]-1 do
          k:=k+trunc((26-i)*(25-i)*(24-i)*(23-i)/24);
          for i:=d[1]+1 to d[2]-1 do
          k:=k+trunc((26-i)*(25-i)*(24-i)/6);
          for i:=d[2]+1 to d[3]-1 do
          k:=k+trunc((26-i)*(25-i)/2);
          for i:=d[3]+1 to d[4]-1 do
          k:=k+26-i;
          k:=k+d[5]-d[4];
          writeln(k);
        end;
      end;
    end;
  end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator