Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	for i := 0; i < n; i++ {
		scanner.Scan()
		points := strings.Split(scanner.Text(), " ")
		fpoints := make([]float64, 0)
		for _, v := range points {
			tmp, _ := strconv.ParseFloat(v, 64)
			fpoints = append(fpoints, tmp)
		}
		if fpoints[0] == fpoints[2] && fpoints[4] == fpoints[6] {
			fmt.Println("YES")
			continue
		}
		a := (fpoints[1]-fpoints[3])/(fpoints[0]-fpoints[2])
		b := (fpoints[5]-fpoints[7])/(fpoints[4]-fpoints[6])
		if a == b {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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;
}

C++: #define _USE_MATH_DEFINES
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	//ごみ
	for(int i=0;i<n;i++){
		double x1, y1, x2, y2, x3, y3, x4, y4;
		cin >> x1 >>y1 >>x2 >>y2 >>x3 >>y3 >>x4 >>y4;
		
		//double t1 = (y1-y2)*(x3-x4);
		//double t2 = (y3-y4)*(x1-x2);

		if( (x1-x2)==0 && (x3-x4)==0 ){
			if( (y1-y2)==0 || (y3-y4)==0 ){
				cout << "NO" << endl;
			}else{
				cout << "YES" << endl;
			}
		}else if( (x1-x2)==0 || (x3-x4)==0 ){
			cout << "NO" << endl;
		}else{
			double t1 = (y1-y2)/(x1-x2);
			double t2 = (y3-y4)/(x3-x4);
			if(t1==t2){
				cout << "YES" << endl;
			}else{
				cout << "NO" << endl;
			}
		}
	}

	return 0;
}

C++: #include<string>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		double a[4][2];
		for (int I = 0; I< 4; I++)
		{
			for (int k = 0; k < 2; k++)
			{
				cin >> a[I][k];
			}
		}
		double x, y;
		x = (a[1][0] - a[0][0]);
		y = (a[3][0] - a[2][0]);
		x = (x) ? (a[1][1] - a[0][1]) / x : 0;
		y = (y) ? (a[3][1] - a[2][1]) / y : 0;
		if (x == y)cout << "YES" << endl;
		else cout << "NO" << endl;
	}

}
/*
		x = (a[1][1] - a[0][1]) / (a[1][0] - a[0][0]);
		y = (a[3][1] - a[2][1]) / (a[3][0] - a[2][0]);*/