比赛 |
20101101 |
评测结果 |
AAAAAAAAAA |
题目名称 |
漂亮字串 |
最终得分 |
100 |
用户昵称 |
Vow Ryan |
运行时间 |
0.012 s |
代码语言 |
Pascal |
内存使用 |
0.17 MiB |
提交时间 |
2012-11-05 11:03:04 |
显示代码纯文本
var
i,j,k,l,m,n:longint;
ans,countO,countX,maxO,maxX,timeO,timeX:int64;
function max(a,b:int64):int64;
begin
if a>b then exit(a) else exit(b);
end;
procedure work;
begin
ans:=max(maxO,maxX);
if maxX=0 then ans:=max(ans,maxO);
if maxO=0 then ans:=max(ans,maxX);
if (maxX=0)or(maxO=0) then exit;
if countO>=maxO*(countX+1) then ans:=max(ans,countX+(countX+1)*maxO);
if countX>=maxX*(countO+1) then ans:=max(ans,countO+(countO+1)*maxX);
if (maxX>=countX)and(maxO>=countO) then ans:=max(ans,countO+countX);
timeO:=countO div maxO;if countO mod maxO<>0 then timeO:=timeO+1;
timeX:=countX div maxX;if countX mod maxX<>0 then timeX:=timeX+1;
if (timeO>=timeX)and(countO<=countX) then ans:=max(ans,countO+countX);
if (timeX>=timeO)and(countX<=countO) then ans:=max(ans,countO+countX);
if (timeX>=timeO)and(timeX<=countO) then ans:=max(ans,countO+countX);
if (timeO>=timeX)and(timeO<=countX) then ans:=max(ans,countO+countX);
if (countX+1=timeO)or(countO+1=timeX) then ans:=max(ans,countO+countX);
end;
begin
assign(input,'bs.in');reset(input);
assign(output,'bs.out');rewrite(output);
while not eof do
begin
readln(countO,countX,maxO,maxX);
if countO<maxO then maxO:=countO;
if countX<maxX then maxX:=countX;
work;
writeln(ans);
end;
close(input);close(output);
end.