x:=16;
While True do
begin
if not ((10*x) mod (x-15)<>0) then
begin
y:=Trunc((10*x)/(x-15));
if 12*x+12*y=X*Y then
begin
showmessage('x='+inttostr(x)+',y='+inttostr(y));
break;
end;
end;
x:=x+1;
end;
While True do
begin
if not ((10*x) mod (x-15)<>0) then
begin
y:=Trunc((10*x)/(x-15));
if 12*x+12*y=X*Y then
begin
showmessage('x='+inttostr(x)+',y='+inttostr(y));
break;
end;
end;
x:=x+1;
end;
document.write "公式12*x+12*y=10*x+15*y"
for x=1 to 100
for y=1 to 100
if 12*x+12*y=10*x+15*y then
document.write "甲的效率:" & x & " 乙的效率:" & y & " 乙单干所需的天数:" & (12*x+12*y)\y & "<br>"
end if
next
next
</script>-------
以上保存成xxx.htm,然后打开就可以了
也就是说甲修2天乙要修3天。
那么,12/2*3+12就是乙单独修的总天数。var
x:integer;
begin
x:=15-12; //甲修2天=乙要修3天
x:=12/2*x; //甲需要修多少个2天*乙要修3天;即将甲的12天换算为乙要修的天数;
x:=x+12; //加上乙修的12天
showmessage(inttostr(x));
end;
begin
if adays=bdays then
showmessage('无解');
result:=(Bdays-adays)/(bothdays-adays)*bothdays ;
end;
procedure button1click(sender:object);
begin
showmessage(floattostr(GetBWorkDays(12,10,10+5));//结果30天
end;
ADays//实际上A修的天数
BDays//实际上B修的天数
返回为B单独修要的天数,可能为一小数。
begin
For i:=10 to 10*15 do
begin
For j:=15 to 10*15 do
if (FormatFloat('0.00',(12/i)+(12/j))='1.00') and
(FormatFloat('0.00',(10/i)+(15/j))='1.00') then
begin
ShowMessage('Ans: '+IntToStr(j));
Exit;
end;
end;
end;
解:设甲每天完成x份,乙每天完成y份
则有以下等式:
12*(x+y)=10*x+(10+5)*y
解出 x/y=1.5 这就是说:如果x=1.5(即甲每天完成1.5份) 则y=1
那么整个工程就是:12*(1.5+1)=30 也就是30份
因为y=1即乙每天只能完成1份
所以30份/(1份/每天)=30 乙单独完成要30天