1.
var
ans,i,x,n:longint;
begin
readln(n);
ans:=-1;
for i:=1 to n do
begin
read(x);
if ans<x then ans:=x;
end;
writeln(ans);
end.
输入:
5
6 5 4 3 2 10
输出:6
2.
var
num:array[0..1000] of longint;
i,x,n:longint;
begin
readln(n);
fillchar(num,sizeof(num),0);
for i:=1 to n do
begin
read(x);
num[x]:=num[x]+1;
end;
readln(x);
writeln(num[x]);
end.
输入:
6
66 63 62 66 60 0
66
输出:2
3.
var
n,i,p,max:longint;
dp,a:array[0..1000] of longint;
function Binary_Search(x:longint):longint;
var
l,r,m,i:longint;
begin
l:=0;
r:=max;
while l+3<r do
begin
m:=(l+r) div 2;
if dp[m]>=x then r:=m-1
else l:=m;
end;
for i:=r downto l do
if dp[i]<x then exit(i);
end;
begin
readln(n);
for i:=1 to n do read(a[i]);
fillchar(dp,sizeof(dp),$20);
dp[0]:=0;
max:=0;
for i:=1 to n do
begin
p:=Binary_Search(a[i]);
p:=p+1;
dp[p]:=a[i];
if p>max then max:=p;
end;
writeln(max);
end.
输入1:
4
4 3 5 1
输入2:
5
4 4 3 5 1
输出:2|2
4.
var
px,py,ax,ay,bx,by:double;
t1x,t1y,t2x,t2y:double;
function Dist(ax,ay,bx,by:double):double;
begin
exit(sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)));
end;
begin
read(px,py,ax,ay,bx,by);
while Dist(ax,ay,bx,by)>1E-10 do
begin
t1x:=(ax*2+bx) / 3;
t1y:=(ay*2+by) / 3;
t2x:=(ax+bx*2) / 3;
t2y:=(ay+by*2) / 3;
if Dist(px,py,t1x,t1y)<Dist(px,py,t2x,t2y) then
begin
bx:=t2x;
by:=t2y;
end
else
begin
ax:=t1x;
ay:=t1y;
end;
end;
writeln(trunc(Dist(px,py,ax,ay)));
end.
输入:
0 0 -1 1 1 1
输出:1