pascal 如何编?

2025-12-17 07:09:41
推荐回答(5个)
回答1:

校门外的树05年竞赛题
so easy
program tree;
var a:array[0..10000]of integer;
Mo:array[1..100,1..100]of integer;
i,j,t,L,M:integer;
begin
read(L,M);readln;
for i:=1 to m do
begin
read(mo[i,1],mo[i,2]);readln;
end;
for i:=0 to L do
a[i]:=1;
for i:=1 to m do
for j:=mo[i,1] to mo[i,2] do
a[j]:=0;
for i:=0 to L do
if a[i]<>0 then inc(t);
writeln(t);
end.

回答2:

var sum,i,j,x,y,n,m:longint;
b:array[0..10000]of boolean;
begin
readln(m,n);
for i:=1 to n do begin
readln(x,y);
for j:=x to y do b[j]:=true;
end;
for i:=0 to m do
if not(b[i]) then inc(sum);
writeln(sum);
end.

回答3:

Program tree;
Const
infile = '';
outfile = '';
Type
Arr = Array[0..10000]Of Integer;
Var
a: Arr;
i, j, n, m, x, b, c: Integer;
Begin
Assign(input, infile);
Reset(input);
For i:=0 To 10000 Do a[i] := 0;
ReadLn(n, m);
For i:=1 To m Do Begin
ReadLn(b, c);
For j:=b To c Do a[j] := 1;
End;
Close(input);
x := 0;
For i:=0 To n Do
If a[i] = 0 Then Inc(x);
Assign(output, outfile);
Rewrite(output);
Write(x);
Close(output);
End.

回答4:

var
b:array[0..10000]of longint;
l,m,x,y,s,i:longint;
begin
readln(l,m);
for i:=1 to l do
b[i]:=0;
for i:=1 to m do
begin
readln(x,y);
while x<>y do
begin
b[x]:=1;
x:=x+1;
end;
end;
for i:=1 to l do
if b[i]=0 then s:=s+1;
writeln(s-1);
end.

回答5:

LS几个要超时的…………
正解是离散化.具体的百毒hi我,不难的