Problem:
-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
-
Describe
-
-
have a N (1<=n<=100) < span= "" > a point that is not coincident and gives their coordinates (xi,yi), asking if the points are in the same line.
-
-
Input
-
The
-
first line is the number of groups of tests T (1<=T<=100), followed by the T-group data, the first row of each group of data is the number of data points of the group N, followed by n rows, each row represents a point of coordinates, consisting of two numbers, the two numbers are separated by a space.
-
-
Output
-
-
there are t rows, each row corresponds to a set of data entered, and if the points in that group of data are on the same line, the row outputs true, otherwise the output is false.
-
-
Sample input
-
-
130 02 21 1
-
-
Sample output
-
-
True
Solution:
#include<iostream>#include<stdio.h>using namespaceStd;int Main(){intT;Cin>>T;intTrue[T];DoubleA[T][ +];DoubleB[T][ +];intC[T]; for(intI=0;I<T;I++){Cin>>C[I]; for(intJ=0;J<C[I];J++){Cin>>A[I][J]>>B[I][J];}} for(intI=0;I<T;I++){True[I]=1; for(intH=1;H<C[I];H++){if(C[I]>2&& (B[I][1]-B[I][0])*(A[I][H]-A[I][0])!=(B[I][H]-B[I][0])*(A[I][1]-A[I][0])){True[I]=0;//cout<<a[i][0]*b[i][h]<< "and" <<a[i][h]*b[i][0]<<endl; Break;}}if(True[I]==1){cout<<"True"<<Endl;}Else{cout<<"False"<<Endl;}}return 0;}
Openjudge Exercise Solution (c + +)-Question 4072: Determine if multiple points are in the same line