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

用pascal的人不多啊

Posted by 1007816143 at 2015-07-29 18:46:31 on Problem 1850
var
  c:array[0..26,0..26]of longint;
  st:string;
  ch,i,sum,len:longint;

procedure db();
var i,j:integer;
begin
  for i:=0 to 26 do
    for j:=0 to i do
      if(j=0)or(j=i)then c[i,j]:=1
      else c[i,j]:=c[i-1,j-1]+c[i-1,j];
  c[0,0]:=0;
end;

begin
  db();
  while not eof do
    begin
      readln(st);
      len:=length(st);
      if len=0 then break;
      for i:=2 to len do
        if st[i-1]>=st[i] then
          begin
            writeln(0);
            halt;
          end;
      sum:=0;
      for i:=1 to len-1 do sum:=sum+c[26,i];
      for i:=1 to len do
        begin
          if i=1 then ch:=97
          else ch:=ord(st[i-1])+1;
          while ch<=ord(st[i])-1 do
            begin
              sum:=sum+c[ord('z')-ch,len-i];
              inc(ch);
            end;
        end;
      writeln(sum+1);
    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