比赛 20101101 评测结果 EEEEEEEEEE
题目名称 漂亮字串 最终得分 0
用户昵称 digital-T 运行时间 0.003 s
代码语言 Pascal 内存使用 0.17 MiB
提交时间 2012-11-05 09:19:03
显示代码纯文本
var
a,b,c,d,maxo,maxx,counto,countx:longint;
function max(x,y:longint):longint;
begin
 if x>=y then max:=x else y:=x;
end;
begin
assign(input,'pc.in');reset(input);
assign(output,'pc.out');rewrite(output);
while not eof do
begin
 read(counto,countx,maxo,maxx);
 if maxo>0 then begin a:=counto div maxo;c:=counto mod maxo;end;
 if maxx>0 then begin b:=countx div maxx;d:=countx mod maxx;end;
 if (counto>0)and(countx>0)and(maxo>0)and(maxx>0)then
  begin
  if a=b then
   write(a*counto+b*countx+max(c,d));
  if (a+1=b)or(b+1=a) then
   write(countx+counto);
  if a>b+1 then
   if maxx=1 then write(b*2+1)
    else  if countx>0 then write((countx+1)*(maxo+1)-1);

  if b>a+1 then
   if maxo=1 then write(a*2+1)
    else if counto>0 then write((counto+1)*(maxx+1)-1);
  writeln;
 end;
 if (counto=0)and(countx=0)then write(0);
 if (counto>0)and(countx=0)then write(maxo);
 if (counto=0)and(countx>0)then write(maxx);
 if (maxo>0)and(maxx=0)then writeln(counto);
 if (maxo=0)and(maxx>0)then writeln(countx);
 if (maxo=0)and(maxx=0)then writeln(0);
end;
close(input);
close(output);
end.