var
n,k,i,j,q,t:longint;
s:string;
temp:char;
str:array[1..200000] of string;
begin
readln(n);
readln(s); t:=0;
k:=length(s);
for j:=1 to k-1 do
for q:=j+1 to k do
if s[j]<s[q] then begin temp:=s[q];s[q]:=s[j];s[j]:=temp; end;
for i:=1 to n do
begin
readln(str[i]);
if length(str[i])=k then
begin
for j:=1 to k-1 do
for q:=j+1 to k do
if str[i][j]<str[i][q] then begin temp:=str[i][q];str[i][q]:=str[i][j];str[i][j]:=temp; end;
if s=str[i] then t:=t+1;
end;
end;
writeln(t);
end.
是这个样子的
排序?冒泡就行了
program brother;
var f,a:array['a'..'z']of integer;
str:string;
i,j,k,m,n,total:longint;
flog:boolean;
ch:char;
begin
readln(n);
total:=0;
readln(str);
k:=length(str);
fillchar(f,sizeof(f),0);
for i:=1 to k do
inc(f[str[i]]);
for i:=1 to n do
begin
readln(str);
m:=length(str);
if m<>k then continue;
a:=f;
for j:=1 to m do
dec(a[str[j]]);
flog:=true;
for ch:='a' to 'z' do
if a[ch]<>0 then
begin
flog:=false;
break;
end;
if flog then inc(total);
end;
writeln(total);
end.
program brother;
var f,a:array['a'..'z']of integer;
str:string;
i,j,k,m,n,total:longint;
flog:boolean;
ch:char;
begin
readln(n);
total:=0;
readln(str);
k:=length(str);
fillchar(f,sizeof(f),0);
for i:=1 to k do
inc(f[str[i]]);
for i:=1 to n do
begin
readln(str);
m:=length(str);
if m<>k then continue;
a:=f;
for j:=1 to m do
dec(a[str[j]]);
flog:=true;
for ch:='a' to 'z' do
if a[ch]<>0 then
begin
flog:=false;
break;
end;
if flog then inc(total);
end;
writeln(total);
end.