2014
03-06

# Different Division

Now we will give you a graph, there are many points in the graph. We will choose two different points arbitrarily, and connect them as a line. Please tell us that whether these points (Include the two points referred above) is on the left side of the line, or lying on the line. or on the right side of the line. For example,

There are four points in the graph: A, B, C, D. we connect C and D. Now C and D form a new line “CD”. Obviously, C and D are lying on the line “CD”. A is on the right side of CD, and B is on the left side of CD. What’s more, A is on the left side of line DC, and B is on the right side of line DC. So line “CD” and “DC” are different in this problem;

The first line of input is a single integer T, indicating the number of test cases. Then exactly T test cases followed. In each case, the first line contains one integer: N, the number of points. Then N lines followed, each line contains two real numbers X, Y, indicating the coordinates of points. Then one line follows, contains two integers P1 and P2 indicate the P1th point and the P2th point in this case.
1<= T <= 100
2 <= N <= 1000
1<= P1, P2 <= N, P1 != P2
-1000 < X, Y < 1000;

The first line of input is a single integer T, indicating the number of test cases. Then exactly T test cases followed. In each case, the first line contains one integer: N, the number of points. Then N lines followed, each line contains two real numbers X, Y, indicating the coordinates of points. Then one line follows, contains two integers P1 and P2 indicate the P1th point and the P2th point in this case.
1<= T <= 100
2 <= N <= 1000
1<= P1, P2 <= N, P1 != P2
-1000 < X, Y < 1000;

1
4
1 1
1 2
3 3
2 1
1 3

On
Left
On
Right

#include <cstdio>
#include <iostream>

using namespace std;

#define N 1005
#define L 0.0000001

double a[N];
double b[N];

int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int i = 0;
for(i = 1; i <= n; i++)
scanf("%lf%lf",&a[i],&b[i]);
int p1,p2;
scanf("%d%d",&p1,&p2);

double x1 = a[p2] - a[p1];
double y1 = b[p2] - b[p1];

for(i = 1; i <= n; i++)
{
double x2 = a[i] - a[p1];
double y2 = b[i] - b[p1];

double sum = x1*y2 - x2*y1;
if(sum < -L)
printf("Right\n");
else if(sum > L)
printf("Left\n");
else printf("On\n");
}
}
return 0;
}

1. #include <stdio.h>
int main()
{
int n,p,t[100]={1};
for(int i=1;i<100;i++)
t =i;
while(scanf("%d",&n)&&n!=0){
if(n==1)
printf("Printing order for 1 pages:nSheet 1, front: Blank, 1n");
else {
if(n%4) p=n/4+1;
else p=n/4;
int q=4*p;
printf("Printing order for %d pages:n",n);
for(int i=0;i<p;i++){
printf("Sheet %d, front: ",i+1);
if(q>n) {printf("Blank, %dn",t[2*i+1]);}
else {printf("%d, %dn",q,t[2*i+1]);}
q–;//打印表前
printf("Sheet %d, back : ",i+1);
if(q>n) {printf("%d, Blankn",t[2*i+2]);}
else {printf("%d, %dn",t[2*i+2],q);}
q–;//打印表后
}
}
}
return 0;
}