标签:des style blog http color os io strong
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 10488 | Accepted: 5031 |
Description
Input
Output
Sample Input
5 6 0 10 60 0 3 1 4 3 6 8 10 10 15 30 1 5 2 1 2 8 5 5 40 10 7 9 4 10 0 10 100 0 20 20 40 40 60 60 80 80 5 10 15 10 25 10 35 10 45 10 55 10 65 10 75 10 85 10 95 10 0
Sample Output
0: 2 1: 1 2: 1 3: 1 4: 0 5: 1 0: 2 1: 2 2: 2 3: 2 4: 2
Hint
1 #include <iostream> 2 #include <cmath> 3 #include <string.h> 4 #include <cstdio> 5 using namespace std; 6 int a[5005],b[5005],c[5005]; 7 int main() 8 { 9 int n,m,x1,y1,x2,y2,i,j,k,x,y,l1,l2,l3,l4; 10 while (scanf("%d%d%d%d%d%d",&n,&m,&x1,&y1,&x2,&y2)==6){ 11 for (i=0;i<5005;i++){ 12 c[i]=0; 13 } 14 b[n]=x2;a[n]=y2; 15 for (i=0;i<n;i++){ 16 scanf("%d%d",&a[i],&b[i]); 17 } 18 for (i=0;i<m;i++){ 19 scanf("%d%d",&x,&y); 20 j=0; 21 while (b[j]<x&&j<n){ 22 j++; 23 } 24 l1=a[j]-x; 25 l2=y1-y; 26 l3=b[j]-x; 27 l4=y2-y; 28 if (l1*l4-l2*l3>0){ 29 while (l1*l4-l2*l3>0&&j<n){ 30 j++; 31 l1=a[j]-x; 32 l2=y1-y; 33 l3=b[j]-x; 34 l4=y2-y; 35 } 36 c[j]++; 37 }else { 38 while (l1*l4-l2*l3<0){ 39 j--; 40 l1=a[j]-x; 41 l2=y1-y; 42 l3=b[j]-x; 43 l4=y2-y; 44 } 45 c[j+1]++; 46 } 47 } 48 for (i=0;i<=n;i++){ 49 printf("%d: %d\n",i,c[i]); 50 } 51 printf("\n"); 52 } 53 return 0; 54 }
2.二分加叉积:
标签:des style blog http color os io strong
原文地址:http://www.cnblogs.com/nwpuzzh/p/3925403.html