1.
program t2014_1;
var s,s1:string;
i,k,n:integer;
begin
s:='abbccdgggvvvvvv33333*';
i:=1;
repeat
n:=1;k:=i+1;
while s[i]=s[k] do begin
n:=n+1;delete(s,k,1);
end;
if n>1 then
begin
str(n,s1);
insert(s1,s,k)
end;
i:=i+1;
until s[i]='*';
writeln(s);
end.
输出:ab2c2dg3v635*
2.
program t2014_2
var n,k:integer;
function s(n,k:integer):longint;
begin
if (n<k)or(k=0) then
s:=0
else if (k=1)or(k=n) then
s:=1
else
s:=s(n-1,k-1)+k*s(n-1,k)
end;
begin
readln(n,k);
writeln(s(n,k));
end.
输入:
5 3
输出:15
3.
program jb2014_3
var
f:array[0..400,0..400] of integer;
n,mv,mw,v,w,x,i,j,k:integer;
function max(a,b:integer):integer;
begin
max:=a;
if max<b then max:=b;
end;
begin
readln(mv,mw);
readln(n);
for k:=1 to n do
begin
readln(v,w,x);
for i:=mv downto v do
for j:=mw downto w do
f[i,j]:=max(f[i,j],f[i-v,j-w]+x);
end;
writeln(f[mv,mw]);
end.
输入:
32 35
4
16 4 12
8 11 24
22 7 31
4 40 22
输出:55
4.
program t2014_4;
var
s:array[1..10000] of string; x:string;
n,i,j,k,max:integer;
begin
readln(n);
readln(s[1]);k:=1; max:=1;
for i:=2 to n do
begin
readln(x);
j:=k;
while (pos(s[j],x)=0) and (j>0) do j:=j-1;
s[j+1]:=x;
if max< j+1 then
begin
max:=j+1;
k:=k+1;
end;
end;
writeln(max);
end.
输入:
10
h
hpe
hpeh
hpehp
hpehxt
hpej
hpeju
hpejuyr
hu
hws
输出:5