- 校门外的树
- 2015-09-17 14:04:42 @
var
tree:array[1..10000]of integer;
i,l,m,a,b,j,t:integer;
begin
read(l,m);
t:=0;
for i:=1 to l do tree[i]:=1;
for i:=1 to m do
begin
read(a,b);
for j:=a to b do tree[j]:=0;
end;
for i:=1 to l do
if tree[i]<>0 then
t:=t+1;
writeln(t);
end.
4 条评论
-
NERvGear LV 8 @ 2015-09-27 09:53:00
#include <iostream>
using namespace std;
int main()
{
int i,j;
int n,m;
cin>>n>>m;
bool l[n+1];
int x,y;
for(i=0;i<=n;i++)
l[i]=true;
for(i=0;i<=n;i++)
{
cin>>x>>y;
for(j=x;j<=y;j++)
{l[j]=false;
}}
int js=0;
for(i=0;i<=n;i++)
{
if(l[i]==true)
js++;
}
cout<<js<<endl;
//system("pause");
return 0;
} -
2015-09-18 20:10:58@
不用了,找到错误了
tree:array[1..10000]of integer改成tree:array[0..10000]of integer
再改一下循环就行了 -
2015-09-17 14:05:12@
求大神
-
2015-09-17 14:04:58@
为什么?
- 1