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")
		} else {
			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>
using namespace std;
#define INF 1e+15

int main(){
	double x1, x2, x3, x4, y1, y2, y3, y4;
	int n;
	cin >> n;
	while( n-- ){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		double tan1, tan2;
		if( x2 - x1 == 0 ){
			tan1 = INF;
		}else{
			tan1 = (x2-x1)*(y4-y3);
		}
		if( x4 - x3 == 0 ){
			tan2 = INF;
		}else{
			tan2 = (x4-x3)*(y2-y1);
		}
		if( tan1 == tan2 ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

C++: #include <iostream>
#include <cmath>
 
using namespace std;
 
const double EPS = 1e-10;
 
int
main()
{
    int n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
 
    cin >> n;
 
    while (n--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
 
        if (fabs((x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1)) < EPS)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
 
    return 0;
}

C++: #include<stdio.h>

int main()
{
	int n;
	double x1,y1,x2,y2,x3,y3,x4,y4;

	scanf("%d",&n);
	for(int x=0;x<n;x++)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);

		x2-=x1;
		y2-=y1;
		x1=0;
		y1=0;
		x4-=x3;
		y4-=y3;
		x3=0;
		y3=0;

		double p,q;
		p=x2/x4;
		q=y2/y4;

		if(p==q)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

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