| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用pascal的人不多啊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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator