var a,b,t,M,R,H :integer;
Function F(H, x: integer):integer;
begin
F := -5*(x-H)*(x-H)+3;
end;
BEGIN
readln(H);
a := -20; b := 60;
M := a; R := F(H, a);
for t := a to b do begin
if (F(H, t) < R) then begin
M := t;
R := F(H, t)
end
end;
write(R)
END.
|
#include<stdio.h>
int F(int H, int x)
{
return(-5*(x-H)*(x-H)+3);
}
int main(void)
{
int a, b, H, t, R, M;
scanf(″%d″, &H);
a = -20; b = 60;
M = a; R = F(H, a);
for (t=a; t<= b; t++)
if (F(H, t) < R)
{
M = t;
R = F(H, t)
}
printf(″%d″, R);
}
|