//给你一些电话工作的时间断,,然后再给你一个监视时间段,问能监视到几个电话,只要时间段有重叠就算有监视到。。简单题。。
#include <iostream>
#include <stdio.h>
using namespace std;
struct phone
{
int Source;
int Des;
int Start;
int During;
};
phone Phone[10001];
int main()
{
int n,m;
int i,j;
int start,end;
int during;
int sum;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n==0&&m==0)
break;
for(i=0;i<n;i++)
{
scanf("%d%d%d%d",&Phone[i].Source,&Phone[i].Des,&Phone[i].Start,&Phone[i].During);
}
for(i=0;i<m;i++)
{
sum=0;
scanf("%d%d",&start,&during);
end=start+during;
for(j=0;j<n;j++)
{
if(Phone[j].Start<start&&Phone[j].Start+Phone[j].During>start)
sum++;
if(Phone[j].Start==start)
sum++;
if(Phone[j].Start>start&&start+during>Phone[j].Start)
sum++;
}
printf("%d\n",sum);
}
}
return 0;
}
转载于:https://www.cnblogs.com/Mu-Tou/archive/2011/10/23/2221671.html