?? lgame.pas
字號:
{
ID:maigoak1
PROG:lgame
}
program lgame;
const
maxdict=40000;
value:array['a'..'z']of byte=(2,5,4,4,1,6,5,5,1,7,6,3,5,2,3,5,7,2,1,2,4,6,6,7,5,7);
type
str7=string[7];
var
fin,fout:text;
dict:array[1..maxdict]of str7;
score:array[1..maxdict]of byte;
dictsize,i,j:word;
usable,s:str7;
top,max,t:byte;
function ok(s:string):boolean;
var
u:str7;
i,p:byte;
begin
ok:=false;
u:=usable;
for i:=1 to length(s) do begin
p:=pos(s[i],u);
if p=0 then exit;
delete(u,p,1);
end;
ok:=true;
end;
function calscore(s:str7):byte;
var
i:byte;
begin
calscore:=0;
for i:=1 to length(s) do
inc(calscore,value[s[i]]);
end;
begin
assign(fin,'lgame.in');
reset(fin);
readln(fin,usable);
close(fin);
dictsize:=0;max:=0;
assign(fin,'lgame.dict');
reset(fin);
readln(fin,s);
repeat
if ok(s) then begin
inc(dictsize);
dict[dictsize]:=s;
score[dictsize]:=calscore(s);
if score[dictsize]>max then max:=score[dictsize];
end;
readln(fin,s);
until s='.';
close(fin);
top:=calscore(usable);
for i:=1 to dictsize-1 do begin
if max=top then break;
for j:=i to dictsize do begin
if ok(dict[i]+dict[j]) then begin
t:=score[i]+score[j];
if t>max then max:=t;
end;
if max=top then break;
end;
end;
assign(fout,'lgame.out');
rewrite(fout);
writeln(fout,max);
for i:=1 to dictsize do begin
if score[i]=max then writeln(fout,dict[i]);
for j:=i+1 to dictsize do
if ok(dict[i]+dict[j]) then
if score[i]+score[j]=max then writeln(fout,dict[i],' ',dict[j]);
end;
close(fout);
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -