记录编号 | 20989 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 漂亮字串 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.023 s | ||
提交时间 | 2010-11-02 09:21:08 | 内存使用 | 0.11 MiB | ||
program bs(input,output); var co,cx,mo,mx:longint; ml:longint; ans,i,j,p:longint; function max(a,b:longint):longint; begin if a>b then max:=b else max:=a; end; begin assign(input,'bs.in'); reset(input); assign(output,'bs.out'); rewrite(output); while not(eof) do begin readln(co,cx,mo,mx); if (mo=0)and(mx=0) then ans:=0 else if (mo=0)and(cx>0) then ans:=max(mx,cx) else if (mx=0)and(co>0) then ans:=max(co,mo) else if (cx=co)and(mx>0)and(mo>0) then ans:=co+cx else begin if co>cx then begin p:=mx; mx:=mo; mo:=p; p:=co; co:=cx; cx:=p; end; ans:=2*co+1; cx:=cx-co-1; p:=0; while p<=co do begin inc(p); if cx-mx+1>=0 then begin inc(ans,mx-1); dec(cx,mx-1); end else begin inc(ans,cx); break; end; end; end; writeln(ans); end; close(input); close(output); end.