标签:dad each etc eps ebe next tchar get number
4 10 0 10 100 0 20 20 80 80 60 60 40 40 5 10 15 10 95 10 25 10 65 10 75 10 35 10 45 10 55 10 85 10 5 6 0 10 60 0 4 3 15 30 3 1 6 8 10 10 2 1 2 8 1 5 5 5 40 10 7 9 0Sample Output
Box 2: 5 Box 1: 4 2: 1
1 #include<cmath> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 #define LL long long 6 using namespace std; 7 struct data{ 8 int U,D; 9 bool operator < (const data &u) const {return U<u.U;} 10 }A[10005]; 11 int n,m,ans[10005],ret[10005]; 12 int uy,dy; 13 int read(){ 14 int x=0,f=1; char ch=getchar(); 15 while (ch<‘0‘||ch>‘9‘){if (ch==‘-‘) f=-f; ch=getchar();} 16 while (ch>=‘0‘&&ch<=‘9‘) x=x*10+ch-‘0‘,ch=getchar(); 17 return x*f; 18 } 19 int cross(int x_0,int y_0,int x_1,int y_1){ 20 return x_0*y_1-x_1*y_0; 21 } 22 int main(){ 23 for (n=read(); n; n=read()){ 24 puts("Box"); 25 m=read(),A[0].U=A[0].D=read(),uy=read(),A[n+1].U=A[n+1].D=read(),dy=read(); 26 for (int i=1; i<=n; i++) A[i].U=read(),A[i].D=read(); 27 sort(A+1,A+1+n); 28 memset(ans,0,sizeof ans); 29 memset(ret,0,sizeof ret); 30 for (int i=1; i<=m; i++){ 31 int x=read(),y=read(); 32 int L=1,R=n+1,mid,pos; 33 while (L<=R){ 34 mid=(L+R)>>1; 35 if (cross(A[mid].U-A[mid].D,uy-dy,x-A[mid].D,y-dy)>0) 36 R=mid-1,pos=mid; else L=mid+1; 37 } 38 ans[pos-1]++; 39 } 40 for (int i=0; i<=n; i++) ret[ans[i]]++; 41 for (int i=1; i<=m; i++) if (ret[i]>0) printf("%d: %d\n",i,ret[i]); 42 } 43 return 0; 44 }
标签:dad each etc eps ebe next tchar get number
原文地址:http://www.cnblogs.com/whc200305/p/7183762.html