1个回答
展开全部
这题评测机有点问题,同一个程序多交几次就能过.
program p1382;
var a,b:ansistring;
procedure min(var s:ansistring);
var i,j,k,l:longint;
begin
l:=length(s);
s:=s+s;
i:=1; j:=2;
k:=0;
while (i<=l)and(j<=l)and(k<l) do
begin
k:=0;
while (k<l)and(s[i+k]=s[j+k]) do inc(k);
if s[i+k]>s[j+k] then inc(i,k+1);
if s[i+k]<s[j+k] then inc(j,k+1);
if i=j then inc(j);
end;
if i>j then i:=j;
s:=copy(s,i,l);
end;
begin
readln(a);
readln(b);
min(a);
min(b);
if a=b then
begin
writeln('Yes');
writeln(a);
end
else writeln('No');
end.
program p1382;
var a,b:ansistring;
procedure min(var s:ansistring);
var i,j,k,l:longint;
begin
l:=length(s);
s:=s+s;
i:=1; j:=2;
k:=0;
while (i<=l)and(j<=l)and(k<l) do
begin
k:=0;
while (k<l)and(s[i+k]=s[j+k]) do inc(k);
if s[i+k]>s[j+k] then inc(i,k+1);
if s[i+k]<s[j+k] then inc(j,k+1);
if i=j then inc(j);
end;
if i>j then i:=j;
s:=copy(s,i,l);
end;
begin
readln(a);
readln(b);
min(a);
min(b);
if a=b then
begin
writeln('Yes');
writeln(a);
end
else writeln('No');
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询