您的位置:首页 > 其它

P1042 乒乓球

2017-02-03 20:06 190 查看

题目描述

每行有20个字母,W代表华华得一分,L代表对手得一分,有不知道多少行,知道E结束,分别输出11分制和21分制下的结果。


样例输入

WWWWWWWWWWWWWWWWWWWW
WWLWE


样例输出

11:0
11:0
1:1

21:0
2:1


思路

O(2n)
模拟,在到达21分或11分制如果相差两分或以上才算一方胜利。


var
i,j,l,m,n:longint;
s,a:ansistring;
begin
readln(a);
s:=s+a;
l:=pos('E',a);
while l=0 do
begin
readln(a);
s:=s+a;
l:=pos('E',a);
end;
for i:=1 to length(s)-1 do
begin
if s[i]='E' then break;
if s[i]='W' then inc(m)
else inc(n);
if (m>=11)or(n>=11) then
if (m-n>=2)or(n-m>=2) then
begin writeln(m,':',n);m:=0;n:=0;end;
end;
writeln(m,':',n);
writeln;
n:=0;m:=0;
for i:=1 to length(s)-1 do
begin
if s[i]='E' then break;
if s[i]='W' then inc(m)
else inc(n);
if (m>=21)or(n>=21) then
if (m-n>=2)or(n-m>=2) then
begin writeln(m,':',n);m:=0;n:=0;end;
end;
writeln(m,':',n);
writeln;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: