Go: package main

import "fmt"

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	var x1, y1, x2, y2, x3, y3, x4, y4 float64
	fmt.Scan(&n)
	for i := 0 ; i < n; i++ {
		fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)
		if abs((x2-x1)*(y4-y3) - (y2-y1)*(x4-x3)) < 1e-10 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
using namespace std;
int main() {
	int n;
	double x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> n;
	for (int z = 0; z < n; z++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double a = 99999, b = 99999;
		a = (x2 - x1)*(y2 - y1);
		b = (x4 - x3)*(y4 - y3);
		if (a == b) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

C++: #include <cstdio>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

typedef complex<double> P;
typedef vector<P> VP;
const double EPF = 1e-6;

#define X real()
#define Y imag()
#define EQ(x,y) (abs(x-y) < EPF)

double dot(P a, P b) {
  return (conj(a)*b).X;
}
double cross(P a, P b) {
  return (conj(a)*b).Y;
}
double distPP(P a, P b) {
  return sqrt(dot(a-b,a-b));
}
P crosspoint(P a, P b, P c, P d) {//ac , bd
  double d1 = cross(d-b,b-a);
  double d2 = cross(d-b,c-a);
  if(EQ(d1,0) & EQ(d2,0)) return a;
  if(EQ(d2,0)) return a;
  return a + (c-a)*d1/d2;
}
P normal_vector(P a) {
  P b(-a.Y, a.X);
  return b;
}
P polar(double r, double theta) {
  P a(r*cos(theta),r*sin(theta));
  return a;
}

int main() {
  int n;
  scanf("%d",&n);
  REP(i,n) {
    double x,y;
    P a,b,c,d;
    scanf("%lf %lf", &x, &y);
    a = P(x,y);
    scanf("%lf %lf", &x, &y);
    b = P(x,y);
    scanf("%lf %lf", &x, &y);
    c = P(x,y);
    scanf("%lf %lf", &x, &y);
    d = P(x,y);
    
    if(EQ(cross(a-b, c-d),0))printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <iterator>
 
using namespace std;
 
int main(){
     
    int n;
     
    float x[4], y[4];
     
    cin >> n;
     
    for(int loop = 0; loop < n; loop++){
        for(int i = 0; i < 4; i++){
            cin >> x[i] >> y[i];
        }
        x[1] -= x[0];
        y[1] -= y[0];
        x[3] -= x[2];
        y[3] -= y[2];
        if(x[3] * y[1] == y[3] * x[1]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
     
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	int n;
	ld x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> n;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		ld dx1 = x2 - x1, dy1 = y2 - y1;
		ld dx2 = x4 - x3, dy2 = y4 - y3;
		if (abs(dx1 * dy2 - dy1 * dx2) < (ld)1e-12 && dx1 * dx2 + dy1 * dy2 > (ld)1e-12) {
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P
{
	double x, y;
};

int main()
{
	vector<P> p(4);

	int n;
	cin >> n;
	
	rep(i, n)
	{
		rep(i, 4)
			cin >> p[i].x >> p[i].y;
	
		if(p[0].x - p[1].x == p[2].x - p[3].x && p[0].y - p[1].y == p[2].y - p[3].y)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

C++: 
4
5
6
7
8
9
10
11
12
13
 
#include <stdio.h>
 
int main()
{
        int n;
        scanf("%d\n", &n);
        while(n--){
                double x1,y1,x2,y2,x3,y3,x4,y4;
                scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
                printf("%s\n",((y1-y2)/(x1-x2))==((y3-y4)/(x3-x4))?"YES":"NO");
        }
        return 0;
}
 

 
Compile Error Logs: 


 
 
Status 
Judge: 1/1  C  CPU: 00.00 sec  Memory: 620 KB  Length: 335 B  2013-01-20 11:56  2013-01-20 11:56  
Results for testcases 
Case # Verdict CPU Time Memory In Out Case Name 
 Case #1: : Accepted  00.00 sec 620 KB    



 < prev | 1 /  1 | next >      : Accepted        00.00 sec        620 KB 

 

Judge Input #1 ( in1.txt | 16 B)  Judge Output #1 ( out1.txt | 16 B) 

In preparation.

  
In preparation.

 

Comments 
 

 Under Construction. 

 
Categories 
 



 
Free Tags

C++: #include<iostream>
using namespace std;
int main() {
	double zhyoxy[4], line1, line2;
	int time;
	cin >> time;
	for (int i = 0; i < time; ++i) {
		for (int i = 0; i < 4; ++i) {
			cin >> zhyoxy[i];
		}
		line1 = (zhyoxy[3] - zhyoxy[1]) / (zhyoxy[2] - zhyoxy[0]);
		for (int i = 0; i < 4; ++i) {
			cin >> zhyoxy[i];
		}
		line2 = (zhyoxy[3] - zhyoxy[1]) / (zhyoxy[2] - zhyoxy[0]);
		if (line1 == line2) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	cin >> time;
	return 0;
}

C++: #include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int i,num;
	double x[4],y[4];
	cin >> num;

	for ( i = 0 ; i< num; i++ ) {
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];

		if(  (x[0]-x[1])*(y[2]-y[3]) == (y[0]-y[1])*(x[2]-x[3])  ){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
struct P{double x,y;}p[4],a,b;
P operator-(P l,P r){P a={l.x-r.x,l.y-r.y};return a;}
int main()
{
	int T;
	for(scanf("%d",&T);T--;)
	{
		int i;
		double c;
		for(i=0;i<4;++i)scanf("%lf%lf",&p[i].x,&p[i].y);
		a=p[0]-p[1],b=p[2]-p[3];
		c=a.x*b.y-a.y*b.x;
		puts(fabs(c)<1e-10?"YES":"NO");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ld = long double;

int main()
{
	int n;
	ld x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> n;
	while (n--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		ld dx1 = x2 - x1, dy1 = y2 - y1;
		ld dx2 = x4 - x3, dy2 = y4 - y3;
		if (abs(dx1 * dy2 - dy1 * dx2) < (ld)1e-11 && dx1 * dx2 + dy1 * dy2 >= (ld)1e-11) {
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	return 0;
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int main(){

	int n;
	cin>>n;
	double x1,y1,x2,y2,x3,y3,x4,y4;
	while(n>0){
		
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;

		
		if((y4-y3)/(x4-x3)==(y2-y1)/(x2-x1))
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		
		n--;
	}
	
	
}

C++: #include <bits/stdc++.h>
#include <vector>
using namespace std;
double x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4, a, b, c, d;

int x;
int main(){
	cin >> x;
	for(int i = 1; i <= x; i++){
		cin >> x_1 >> y_1 >> x_2 >> y_2 >> x_3 >> y_3 >> x_4 >> y_4;
		a = x_2 - x_1;
		b = y_2 - y_1;
		c = x_4 - x_3;
		d = y_4 - y_3;
		if(a * d == b * c){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
	}
	return 0;
}