text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
int func(long long int A1, long long int A2, long long int B1, long long int B2,
long long int C1, long long int C2) {
long long int divider = C1 * C1 + C2 * C2;
long long int top1 = C1 * (B1 - A1) + C2 * (B2 - A2);
long long int top2 = C1 * (B2 - A2) - C2 * (B1 - A1);
if (divider == 0) {
bool chk1 = B1 == A1 && B2 == A2, chk2 = B1 == -A2 && B2 == A1,
chk3 = B1 == -A1 && B2 == -A2, chk4 = B1 == A2 && B2 == -A1;
if (chk1 || chk2 || chk3 || chk4) {
cout << "YES" << endl;
return 1;
}
return 0;
}
if (top1 % divider == 0 && top2 % divider == 0) {
cout << "YES" << endl;
return 1;
}
return 0;
}
int main(void) {
long long int A1, A2, B1, B2, C1, C2;
cin >> A1 >> A2 >> B1 >> B2 >> C1 >> C2;
if (func(A1, A2, B1, B2, C1, C2) || func(A1, A2, -B2, B1, C1, C2) ||
func(A1, A2, -B1, -B2, C1, C2) || func(A1, A2, B2, -B1, C1, C2))
return 0;
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long bx, by;
bool f(long long cx, long long cy, long long ax, long long ay) {
long long dx = ax - bx;
long long dy = ay - by;
if (dx == 0 && dy == 0) return true;
if (cx == 0 && cy == 0) return false;
if (cx == 0) {
if (dx % cy == 0 && dy % cy == 0)
return true;
else
return false;
}
if (cy == 0) {
if (dx % cx == 0 && dy % cx == 0)
return true;
else
return false;
}
if ((cx * dx + cy * dy) % (cx * cx + cy * cy) == 0 &&
(-cy * dx + cx * dy) % (cx * cx + cy * cy) == 0)
return true;
else
return false;
}
int main() {
long long ax, ay;
long long cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
cout << ((f(cx, cy, ax, ay) || f(cx, cy, -ay, ax) || f(cx, cy, -ax, -ay) ||
f(cx, cy, ay, -ax))
? "YES"
: "NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
const int MAXV = 507;
const int MAXE = 507;
const int INF = 0x3f3f3f3f;
long long d[4][2];
long long ax, ay, bx, by, cx, cy;
int main() {
while (cin >> ax >> ay) {
cin >> bx >> by >> cx >> cy;
d[0][0] = ax, d[0][1] = ay;
d[1][0] = ay, d[1][1] = -ax;
d[2][0] = -ax, d[2][1] = -ay;
d[3][0] = -ay, d[3][1] = ax;
bool found = false;
for (int cas = 0; cas < 4; cas++) {
long long ex = bx - d[cas][0], ey = by - d[cas][1];
if (cx == 0 && cy == 0) {
if (ex == 0 && ey == 0) {
found = true;
break;
}
} else if ((ex * cy - ey * cx) % (cx * cx + cy * cy) == 0 &&
(ex * cx + ey * cy) % (cx * cx + cy * cy) == 0) {
found = true;
break;
}
}
if (found)
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
void check(long long axx, long long ayy) {
if (cx * cx + cy * cy == 0) {
if (axx == bx && ayy == by) {
cout << "YES";
exit(0);
} else
return;
}
if ((cx * (by - ayy) - cy * (bx - axx)) % (cx * cx + cy * cy) != 0 ||
(cx * (bx - axx) + cy * (by - ayy)) % (cx * cx + cy * cy) != 0)
return;
cout << "YES";
exit(0);
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
check(ax, ay);
check(ay, -ax);
check(-ax, -ay);
check(-ay, ax);
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
bool gao(long long A, long long B, long long C, long long D, long long E,
long long F) {
long long R = A * E - B * D;
if (!R)
return !C && !F;
else
return (C * E - B * F) % R == 0 && (C * D - A * F) % R == 0;
}
int main() {
long long x[3], y[3];
for (int i = 0; i < 3; i++) scanf("%I64d%I64d", x + i, y + i);
for (int i = 0; i < 4; i++) {
if (gao(-y[2], x[2], x[1] - x[0], x[2], y[2], y[1] - y[0]))
return puts("YES");
swap(x[0], y[0] *= -1);
}
puts("NO");
}
|
#include <bits/stdc++.h>
using namespace std;
void ASS(bool b) {
if (!b) {
++*(int*)0;
}
}
struct P {
int x, y;
P() {}
P(int xx, int yy) {
x = xx;
y = yy;
}
P rot() { return P(y, -x); }
P operator-(P p) { return P(x - p.x, y - p.y); }
void read() { cin >> x >> y; }
bool eq(const P& p) const { return x == p.x && y == p.y; }
};
long long Dot(P a, P b) { return a.x * (long long)b.y - b.x * (long long)a.y; }
long long gcd(long long a, long long b) {
if (a == 0 || b == 0) return a + b;
a = max(a, -a);
b = max(b, -b);
while (a) {
long long c = b % a;
b = a;
a = c;
}
return b;
}
bool Ok(P A, P B, P C) {
if (A.eq(B)) return 1;
P c0(C.x, C.y);
P c1(C.y, -C.x);
P c = B - A;
long long d = Dot(c0, c1);
if (d == 0) return 0;
ASS(d != 0);
long long L0 = Dot(c, c1);
long long L1 = Dot(c0, c);
return L0 % d == 0 && L1 % d == 0;
}
int main() {
P a, b, c;
a.read();
b.read();
c.read();
for (int za = 0; za < (int)(4); za++) {
for (int zb = 0; zb < (int)(4); zb++) {
for (int zc = 0; zc < (int)(4); zc++) {
if (Ok(a, b, c)) {
cout << "YES" << endl;
return 0;
}
c = c.rot();
}
b = b.rot();
}
a = a.rot();
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T& num) {
char CH;
bool F = false;
for (CH = getchar(); CH < '0' || CH > '9'; F = CH == '-', CH = getchar())
;
for (num = 0; CH >= '0' && CH <= '9';
num = num * 10 + CH - '0', CH = getchar())
;
F && (num = -num);
}
long long ax, ay, bx, by, cx, cy;
int solve(long long x, long long y) {
x = bx - x;
y = by - y;
if (cx == 0 && cy == 0) {
if (x == 0 && y == 0) return 1;
return 0;
} else if (cx == 0) {
long long g = x / cy, h = y / cy;
if (g * cy == x && h * cy == y) return 1;
return 0;
} else if (cy == 0) {
long long g = x / cx, h = y / cx;
if (g * cx == x && h * cx == y) return 1;
return 0;
} else {
long long tx = x * cy, ty = y * cx;
long long b = (tx - ty) / (cy * cy + cx * cx);
if (b * (cx * cx + cy * cy) != (tx - ty))
return 0;
else {
long long a = (x - b * cy) / cx;
if (a * cx + b * cy == x) return 1;
return 0;
}
}
}
int main() {
read(ax);
read(ay);
read(bx);
read(by);
read(cx);
read(cy);
int f = 0;
if (solve(ax, ay)) f = 1;
if (solve(-ax, -ay)) f = 1;
if (solve(ay, -ax)) f = 1;
if (solve(-ay, ax)) f = 1;
if (f)
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
long long x1, botva, x2, y2, x3, y3;
void sw(long long &x, long long &y) {
swap(x, y);
y *= (-1);
}
long long abs1(long long a) {
if (a < 0) return -a;
return a;
}
bool f(long long x, long long y, long long k1, long long k2) {
if (x * x + y * y == 0) return (k1 == 0 && k2 == 0);
return ((abs1(k2 * x - k1 * y) % (x * x + y * y)) == 0 &&
(abs1(k1 * x + k2 * y) % (x * x + y * y)) == 0);
}
int main() {
cin >> x1 >> botva >> x2 >> y2 >> x3 >> y3;
bool q = false;
for (int i = 0; i < int(4); i++) {
q |= f(x3, y3, x2 - x1, y2 - botva);
sw(x2, y2);
}
if (!q)
printf("NO");
else
printf("YES");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool Check(long long A, long long B, long long T1, long long T2) {
if (!A && !B) return !T1 && !T2;
return !((T1 * A + T2 * B) % (A * A + B * B)) &&
!((T2 * A - T1 * B) % (A * A + B * B));
}
int main() {
long long X0, Y0, X1, Y1, X2, Y2;
cin >> X0 >> Y0 >> X1 >> Y1 >> X2 >> Y2;
cout << ((Check(X2, Y2, X1 - X0, Y1 - Y0) ||
Check(X2, Y2, Y1 - X0, -X1 - Y0) ||
Check(X2, Y2, -X1 - X0, -Y1 - Y0) ||
Check(X2, Y2, -Y1 - X0, X1 - Y0))
? "YES"
: "NO")
<< endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
void check(long long axx, long long ayy) {
if (cx == 0 && cy == 0) {
if (axx == bx && ayy == by) {
cout << "YES";
exit(0);
} else
return;
}
if ((cx * (by - ayy) - cy * (bx - axx)) % (cx * cx + cy * cy) != 0 ||
(cx * (bx - axx) + cy * (by - ayy)) % (cx * cx + cy * cy) != 0)
return;
cout << "YES";
exit(0);
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
check(ax, ay);
check(ay, -ax);
check(-ax, -ay);
check(-ay, ax);
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = -1;
long long x1, x2, x3, aoduiaosdiaosid, y2, y3;
void rot() {
long long v = aoduiaosdiaosid;
long long w = -x1;
x1 = v;
aoduiaosdiaosid = w;
}
int main() {
while (scanf("%lld%lld%lld%lld%lld%lld", &x1, &aoduiaosdiaosid, &x2, &y2, &x3,
&y3) >= 1) {
if (x3 == 0 && y3 == 0) {
bool ok = false;
for (int i = (0); i < (int)(4); i++) {
if (x1 == x2 && aoduiaosdiaosid == y2) ok = true;
rot();
}
printf("%s\n", ok ? "YES" : "NO");
continue;
}
bool can = false;
for (int z = (0); z < (int)(4); z++) {
bool ok = true;
if (x3 == 0) {
if ((x2 - x1) % y3) ok = false;
if ((y2 - aoduiaosdiaosid) % y3) ok = false;
if (ok) {
can = true;
break;
}
} else {
long long nom = y3 * (x2 - x1) - x3 * (y2 - aoduiaosdiaosid);
long long den = x3 * x3 + y3 * y3;
if (nom % den)
ok = false;
else {
long long q = nom / den;
if ((x2 - x1 - q * y3) % x3) ok = false;
}
}
if (ok) {
can = true;
break;
}
rot();
}
printf("%s\n", can ? "YES" : "NO");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int IsMultiplyOverflow(long long multiplicant1, long long multiplicant2,
long long overflow_limit) {
if (multiplicant2 == 0LL) return overflow_limit < 0LL;
return multiplicant1 > overflow_limit / multiplicant2;
}
class BigInt {
public:
BigInt() : digits_(1, 0), is_non_negative_(1) {}
BigInt(long long initial_value) {
if (initial_value < 0LL) {
is_non_negative_ = 0;
initial_value *= -1LL;
} else {
is_non_negative_ = 1;
}
if (initial_value == 0) {
digits_.push_back(0);
}
while (initial_value) {
digits_.push_back(initial_value % (long long)kDigitSize);
initial_value /= (long long)kDigitSize;
}
}
BigInt(const string& initial_value) { ParseFromString(initial_value); }
void ParseFromString(string initial_value) {
*this = 0;
this->is_non_negative_ = 1;
int negative = 0;
if (initial_value[0] == '-') {
negative = 1;
initial_value = initial_value.substr(1, initial_value.size());
}
assert(initial_value.size() > 0);
for (int i = 0; i < (int)initial_value.size(); ++i) {
assert(initial_value[i] >= '0' && initial_value[i] <= '9');
long long value = initial_value[i] - '0';
*this *= 10;
*this += value;
}
if (negative) {
this->is_non_negative_ = 0;
}
this->Normalize();
}
BigInt(const BigInt& that) {
this->is_non_negative_ = that.is_non_negative_;
this->digits_ = that.digits_;
}
~BigInt() {}
BigInt& operator=(const BigInt& that) {
this->is_non_negative_ = that.is_non_negative_;
this->digits_ = that.digits_;
return *this;
}
int Size() const { return (int)digits_.size(); }
long long ToLongLong() const {
long long ret = 0LL;
for (int i = Size() - 1; i >= 0; --i) {
assert(!IsMultiplyOverflow(ret, kDigitSize, 9223372036854775807));
ret *= (long long)kDigitSize;
ret += (long long)digits_[i];
}
if (!is_non_negative_) ret *= -1LL;
return ret;
}
string ToString(int base = 10) const {
assert(base >= 2);
static string alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
assert(base <= (int)alphabet.size());
BigInt this_copy = *this;
if (this_copy == 0) return "0";
vector<char> ret;
int negative = 0;
if (this_copy.is_non_negative_ == 0) {
negative = 1;
this_copy = this_copy.Absolute();
}
while (this_copy > 0) {
ret.push_back(alphabet[(this_copy % base).ToLongLong()]);
this_copy /= base;
}
reverse(ret.begin(), ret.end());
string ret_value = "";
for (size_t i = 0; i < ret.size(); ++i) {
ret_value += ret[i];
}
if (negative) ret_value = "-" + ret_value;
return ret_value;
}
bool operator==(const BigInt& that) const {
return this->is_non_negative_ == that.is_non_negative_ &&
this->digits_ == that.digits_;
}
bool operator!=(const BigInt& that) const { return !this->operator==(that); }
BigInt Absolute() const {
BigInt copy_of_this(*this);
copy_of_this.is_non_negative_ = 1;
return copy_of_this;
}
BigInt AntiAbsolute() const {
BigInt copy_of_this(*this);
if (*this == 0LL) return copy_of_this;
copy_of_this.is_non_negative_ = 0;
return copy_of_this;
}
BigInt operator-() const {
BigInt copy_of_this(*this);
copy_of_this.is_non_negative_ ^= 1;
copy_of_this.Normalize();
return copy_of_this;
}
bool operator<(const BigInt& that) const {
if (!this->is_non_negative_) {
if (that.is_non_negative_) {
return true;
} else {
return that < this->Absolute();
}
} else {
if (!that.is_non_negative_) {
return false;
}
if (this->Size() != that.Size()) {
return this->Size() < that.Size();
}
for (int i = this->Size() - 1; i >= 0; --i) {
if (this->digits_[i] < that.digits_[i]) return true;
if (this->digits_[i] > that.digits_[i]) return false;
}
return false;
}
}
bool operator>(const BigInt& that) const { return that < *this; }
bool operator<=(const BigInt& that) const {
return *this == that || *this < that;
}
bool operator>=(const BigInt& that) const {
return *this == that || *this > that;
}
BigInt operator+(const BigInt& that) const {
if (this->is_non_negative_ != that.is_non_negative_) {
if (this->is_non_negative_)
return *this - that.Absolute();
else
return that - this->Absolute();
}
BigInt ret = 0LL;
ret.is_non_negative_ = this->is_non_negative_;
ret.digits_.clear();
int carry = 0;
for (int i = 0; carry || (i < max(this->Size(), that.Size())); ++i) {
int left = 0;
if (this->Size() > i) left = this->digits_[i];
int right = 0;
if (that.Size() > i) right = that.digits_[i];
int sum = left + right + carry;
ret.digits_.push_back(sum % kDigitSize);
carry = sum / kDigitSize;
}
ret.Normalize();
return ret;
}
BigInt operator-(const BigInt& that) const {
if (this->is_non_negative_ != that.is_non_negative_) {
BigInt copy_of_that(that);
copy_of_that.is_non_negative_ ^= 1;
return *this + copy_of_that;
}
if (!this->is_non_negative_) {
return that.Absolute() - this->Absolute();
}
if (that > *this) {
BigInt ret = that - *this;
return ret.AntiAbsolute();
}
assert(this->Size() >= that.Size());
int borrow = 0;
BigInt ret;
ret.digits_.clear();
for (int i = 0; i < this->Size(); ++i) {
int left = this->digits_[i];
int right = 0;
if (that.Size() > i) right = that.digits_[i];
int sum = left - right - borrow;
borrow = 0;
while (sum < 0) {
++borrow;
sum += kDigitSize;
}
ret.digits_.push_back(sum);
}
assert(borrow == 0);
ret.Normalize();
return ret;
}
BigInt& operator+=(const BigInt& that) { return operator=(*this + that); }
BigInt& operator-=(const BigInt& that) { return operator=(*this - that); }
BigInt& operator++() { return this->operator+=(1); }
BigInt operator++(int) {
BigInt ret(*this);
++(*this);
return ret;
}
BigInt& operator--() { return this->operator-=(1); }
BigInt operator--(int) {
BigInt ret(*this);
--(*this);
return ret;
}
BigInt operator<<(const BigInt& that) const {
assert(this->is_non_negative_);
long long amount = that.ToLongLong();
assert(amount >= 0LL);
long long shift_digit = amount / kDigitSizeLog;
vector<int> shifted_digits(shift_digit, 0);
BigInt ret(*this);
ret.digits_.insert(ret.digits_.begin(), shifted_digits.begin(),
shifted_digits.end());
ret.Normalize();
return ret.SlowMultiplication(1 << (amount % kDigitSizeLog));
}
BigInt& operator<<=(const BigInt& that) {
return this->operator=(*this << that);
}
BigInt operator>>(const BigInt& that) const {
assert(this->is_non_negative_);
long long amount = that.ToLongLong();
assert(amount >= 0LL);
long long shift_digit = amount / kDigitSizeLog;
if (this->Size() <= shift_digit) return 0;
BigInt this_copy(*this);
this_copy.digits_.erase(this_copy.digits_.begin(),
this_copy.digits_.begin() + shift_digit);
long long remain = amount % kDigitSizeLog;
int carry = 0;
for (int i = this_copy.Size() - 1; i >= 0; --i) {
this_copy.digits_[i] += (carry << kDigitSizeLog);
carry = this_copy.digits_[i] % (1 << remain);
this_copy.digits_[i] >>= remain;
}
this_copy.Normalize();
return this_copy;
}
BigInt& operator>>=(const BigInt& that) {
return this->operator=(*this >> that);
}
BigInt SlowMultiplication(const BigInt& that) const {
if (that.Size() < this->Size()) {
return that.SlowMultiplication(*this);
}
BigInt ret;
ret.digits_ = vector<int>(this->Size() + that.Size());
ret.is_non_negative_ = !(this->is_non_negative_ ^ that.is_non_negative_);
for (int i = 0; i < this->Size(); ++i) {
int carry = 0;
int inner_carry = 0;
for (int j = 0; j < that.Size(); ++j) {
int mult = this->digits_[i] * that.digits_[j] + carry;
ret.digits_[i + j] += mult % kDigitSize;
carry = mult / kDigitSize;
ret.digits_[i + j] += inner_carry;
inner_carry = ret.digits_[i + j] / kDigitSize;
ret.digits_[i + j] %= kDigitSize;
}
ret.digits_[i + that.Size()] += carry + inner_carry;
int position = i + that.Size();
while (ret.digits_[position] >= kDigitSize) {
ret.digits_[position + 1] += ret.digits_[position] / kDigitSize;
ret.digits_[position] %= kDigitSize;
++position;
}
}
ret.Normalize();
return ret;
}
BigInt operator*(const BigInt& that) const {
if (that.Size() < this->Size()) {
return that * *this;
}
if (this->Size() <= 4 ||
this->Size() * that.Size() <= (int)floor(pow(that.Size(), 1.6)) / 16) {
return this->SlowMultiplication(that);
} else {
int digitviding_line = (that.Size() + 1) / 2;
BigInt xlarge, xsmall;
BigInt ylarge, ysmall;
xlarge.digits_.clear();
xlarge.is_non_negative_ = true;
xsmall.digits_.clear();
xsmall.is_non_negative_ = true;
ylarge.digits_.clear();
ylarge.is_non_negative_ = true;
ysmall.digits_.clear();
ysmall.is_non_negative_ = true;
for (int i = 0; i < digitviding_line; ++i) {
int xsmallbit = 0;
int xlargebit = 0;
int ysmallbit = 0;
int ylargebit = 0;
if (this->Size() > i) xsmallbit = this->digits_[i];
if (this->Size() > i + digitviding_line)
xlargebit = this->digits_[i + digitviding_line];
if (that.Size() > i) ysmallbit = that.digits_[i];
if (that.Size() > i + digitviding_line)
ylargebit = that.digits_[i + digitviding_line];
xsmall.digits_.push_back(xsmallbit);
xlarge.digits_.push_back(xlargebit);
ysmall.digits_.push_back(ysmallbit);
ylarge.digits_.push_back(ylargebit);
}
xsmall.Normalize();
xlarge.Normalize();
ysmall.Normalize();
ylarge.Normalize();
BigInt biggest = xlarge * ylarge;
BigInt smallest = xsmall * ysmall;
BigInt avg = ((xsmall + xlarge) * (ysmall + ylarge)) - biggest - smallest;
biggest <<= (long long)digitviding_line * 2 * kDigitSizeLog;
avg <<= (long long)digitviding_line * kDigitSizeLog;
BigInt result = biggest + avg + smallest;
result.is_non_negative_ =
!(this->is_non_negative_ ^ that.is_non_negative_);
result.Normalize();
return result;
}
}
BigInt& operator*=(const BigInt& that) {
return this->operator=(*this * that);
}
BigInt operator/(const BigInt& that) const {
int max_add = 0;
BigInt that_copy(that.Absolute());
BigInt this_copy(this->Absolute());
while (that_copy <= this_copy) {
++max_add;
that_copy <<= 1;
}
if (max_add == 0) {
return 0;
}
BigInt ret;
ret.digits_ = vector<int>(1 + max_add / kDigitSizeLog);
ret.is_non_negative_ = !(this->is_non_negative_ ^ that.is_non_negative_);
for (int i = max_add - 1; i >= 0; --i) {
that_copy >>= 1;
if (this_copy >= that_copy) {
int digit_position = i / kDigitSizeLog;
int digit_offset = i % kDigitSizeLog;
ret.digits_[digit_position] += (1 << digit_offset);
this_copy -= that_copy;
}
}
ret.Normalize();
return ret;
}
BigInt operator%(const BigInt& that) const {
assert(that.is_non_negative_);
assert(this->is_non_negative_);
assert(that != 0);
return *this - ((*this / that) * that);
}
BigInt& operator/=(const BigInt& that) {
return this->operator=(*this / that);
}
BigInt& operator%=(const BigInt& that) {
return this->operator=(*this % that);
}
friend ostream& operator<<(ostream& out, BigInt& obj) {
out << obj.ToString();
return out;
}
friend istream& operator>>(istream& in, BigInt& obj) {
string rep;
in >> rep;
obj.ParseFromString(rep);
return in;
}
private:
void Normalize() {
while (this->Size() > 1 && digits_.back() == 0) {
digits_.pop_back();
}
if (this->Size() == 1 && this->digits_[0] == 0) {
is_non_negative_ = 1;
}
}
static const int kDigitSize = (1 << 15);
static const int kDigitSizeLog = 15;
vector<int> digits_;
int is_non_negative_;
};
pair<BigInt, BigInt> transform(const pair<BigInt, BigInt>& org, BigInt dir) {
if (dir == 0) {
return org;
} else if (dir == 1) {
return make_pair(org.second, -(org.first));
} else if (dir == 2) {
return make_pair(-(org.first), -(org.second));
} else {
return make_pair(-(org.second), org.first);
}
}
BigInt dir1[] = {0, 0, 2, 2};
BigInt dir2[] = {1, 3, 1, 3};
void ok() {
cout << "YES" << endl;
exit(0);
}
BigInt GreatestCommonDivisor(BigInt abc, BigInt def) {
if (abc < 0LL || def < 0LL)
return GreatestCommonDivisor(abc.Absolute(), def.Absolute());
if (abc < def) return GreatestCommonDivisor(def, abc);
if (def == 0) return abc;
return GreatestCommonDivisor(def, abc % def);
}
int solve(BigInt x1, BigInt x2, BigInt x3) {
return x3 % GreatestCommonDivisor(x1, x2) == 0LL;
}
int main() {
pair<BigInt, BigInt> a;
cin >> a.first >> a.second;
pair<BigInt, BigInt> t;
cin >> t.first >> t.second;
pair<BigInt, BigInt> b;
cin >> b.first >> b.second;
for (int(i) = 0; (i) < (4); ++(i)) {
pair<BigInt, BigInt> trans = transform(a, i);
pair<BigInt, BigInt> target =
make_pair(t.first - trans.first, t.second - trans.second);
if (target.first == 0 && target.second == 0) {
cout << "YES" << endl;
return 0;
}
if (b.first == 0 && b.second == 0) {
continue;
}
for (int(j) = 0; (j) < (4); ++(j)) {
BigInt d1 = dir1[j];
BigInt d2 = dir2[j];
pair<BigInt, BigInt> trans1, trans2;
trans1 = transform(b, d1);
trans2 = transform(b, d2);
BigInt x1 = trans1.first;
BigInt y1 = trans1.second;
BigInt x2 = trans2.first;
BigInt y2 = trans2.second;
BigInt x3 = target.first;
BigInt y3 = target.second;
if (x1 == 0LL && x2 == 0LL && x3 != 0LL) continue;
if (y1 == 0LL && y2 == 0LL && y3 != 0LL) continue;
if (x1 == 0LL && x2 == 0LL && x3 == 0LL) {
if (solve(y1, y2, y3)) ok();
} else if (y1 == 0LL && y2 == 0LL && y3 == 0LL) {
if (solve(x1, x2, x3)) ok();
} else {
BigInt gcdx = GreatestCommonDivisor(x1, GreatestCommonDivisor(x2, x3));
BigInt gcdy = GreatestCommonDivisor(y1, GreatestCommonDivisor(y2, y3));
x1 /= gcdx;
x2 /= gcdx;
x3 /= gcdx;
y1 /= gcdy;
y2 /= gcdy;
y3 /= gcdy;
BigInt det = x1 * y2 - x2 * y1;
if (det == 0LL) {
if (solve(x1, x2, x3) && solve(y1, y2, y3)) ok();
continue;
}
BigInt xnum = x2 * y3 - x3 * y2;
BigInt xden = x2 * y1 - x1 * y2;
if (xnum.Absolute() % xden.Absolute() != 0LL) continue;
BigInt ynum = x1 * y3 - x3 * y1;
if (ynum.Absolute() % xden.Absolute() != 0LL) continue;
ok();
}
}
}
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long bx, by, cx, cy;
long long det(long long a, long long b, long long c, long long d) {
return a * d - b * c;
}
bool solve(long long ax, long long ay) {
long long dx = bx - ax;
long long dy = by - ay;
long long d = det(cx, cy, cy, -cx);
if (d == 0) {
return ((cx != 0 || cy != 0) && cy * dx == cx * dy &&
cy * dy == -cx * dx) ||
(cx == 0 && cy == 0 && dx == 0 && dy == 0);
} else {
return ((det(dx, cy, dy, -cx) % d == 0) && (det(cx, dx, cy, dy) % d == 0));
}
}
int main() {
long long ax, ay;
cin >> ax >> ay >> bx >> by >> cx >> cy;
bool res = false;
res |= solve(ax, ay);
res |= solve(ay, -ax);
res |= solve(-ax, -ay);
res |= solve(-ay, ax);
if (res)
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int x2, y2, x3, y3;
bool check(long long int x, long long int y) {
long long int xx = x3 * x3 + y3 * y3, tx = x2 + x, ty = y2 + y;
if (xx == 0) return x == x2 && y == y2;
long long int ret1 = tx * x3 + ty * y3, ret2 = tx * y3 - ty * x3;
if (ret1 % xx != 0 || ret2 % xx != 0) return false;
return true;
}
int main() {
long long int x1, y1;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
if (check(x1, y1) || check(-x1, -y1) || check(-y1, x1) || check(y1, -x1))
cout << "YES\n";
else
cout << "NO\n";
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
int x[3], y[3];
long long det(long long a, long long b, long long c, long long d) {
return a * d - b * c;
}
int main() {
for (int i(0); i < (3); i++) cin >> x[i] >> y[i];
for (int i(0); i < (4); i++) {
swap(x[0], y[0]);
y[0] = -y[0];
int a = x[1] - x[0];
int b = y[1] - y[0];
long long d = det(x[2], y[2], y[2], -x[2]);
long long d1 = det(a, y[2], b, -x[2]);
long long d2 = det(x[2], a, y[2], b);
if (d == 0) {
if (a == 0 && b == 0) {
puts("YES");
return 0;
}
} else {
if (d < 0) d = -d;
if (d1 % d == 0 && d2 % d == 0) {
puts("YES");
return 0;
}
}
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
long long int x, y, S, T, a, b;
int AC = 0;
int f(long long int S, long long int T) {
if (x == S && y == T) return 1;
if (a == 0 && b == 0) return 0;
long long int A = b, B = a, C = S - x, D = -a, E = b, F = T - y;
long long int DET = A * E - B * D, DX = B * F - C * E, DY = A * F - C * D;
if (DX % DET == 0 && DY % DET == 0)
return 1;
else
return 0;
}
int main() {
scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &x, &y, &S, &T, &a, &b);
AC = 0;
AC = f(S, T) || f(-T, S) || f(-S, -T) || f(T, -S);
printf("%s\n", AC ? "YES" : "NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Point {
long long x, y;
Point(long long _x = 0, long long _y = 0) : x(_x), y(_y) {}
void input() { scanf("%lld%lld", &x, &y); }
void output() { printf("(%lld %lld)\n", x, y); }
};
Point operator+(Point A, Point B) { return Point(A.x + B.x, A.y + B.y); }
Point operator-(Point A, Point B) { return Point(A.x - B.x, A.y - B.y); }
Point Rotate(Point A) { return Point(-A.y, A.x); }
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
int main() {
int ok = 0;
Point A, B, C1, C2, F;
A.input();
B.input();
C1.input();
C2 = Rotate(C1);
for (int i = 0; i < 4; i++) {
A = Rotate(A);
F = B - A;
ok = 0;
long long a1 = C1.x, b1 = C2.x;
long long a2 = C1.y, b2 = C2.y;
long long c1 = F.x, c2 = F.y;
if (a2 == 0 && b2 == 0) swap(a1, a2), swap(b1, b2), swap(c1, c2);
if (a1 == 0 && b1 == 0) {
if (c1) {
ok = 0;
} else if (a2 == 0 && b2 == 0) {
if (c2)
ok = 0;
else
ok = 1;
} else if (c2 % gcd(a2, b2) == 0)
ok = 1;
else
ok = 0;
} else if (c1 % gcd(a1, b1) || c2 % gcd(a2, b2)) {
ok = 0;
} else if (a1 * b2 == a2 * b1) {
if (a1 * c2 == a2 * c1 && b1 * c2 == b2 * c1) {
ok = 1;
}
ok = 0;
} else if ((b1 * c2 - b2 * c1) % (a1 * b2 - a2 * b1)) {
ok = 0;
} else if ((c1 * a2 - c2 * a1) % (b1 * a2 - a1 * b2)) {
ok = 0;
} else
ok = 1;
if (ok == 1) break;
}
printf(ok ? "YES\n" : "NO\n");
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int inf = 1 << 28;
int getint() {
unsigned int c;
int x = 0;
while (((c = getchar()) - '0') >= 10) {
if (c == '-') return -getint();
if (!~c) exit(0);
}
do {
x = (x << 3) + (x << 1) + (c - '0');
} while (((c = getchar()) - '0') < 10);
return x;
}
void rot90(int& rx, int& ry, int x, int y) { rx = -y, ry = x; }
int solve_le(long long& x, long long& y, const vector<long long>& v1,
const vector<long long>& v2) {
long long den = v1[0] * v2[1] - v2[0] * v1[1];
if (den != 0) {
x = (v1[2] * v2[1] - v2[2] * v1[1]) / den;
y = (v1[0] * v2[2] - v2[0] * v1[2]) / den;
return 1;
}
den = v1[2] * v2[1] - v1[1] * v2[2];
if (den != 0) return 0;
den = v1[0] * v2[2] - v1[2] * v2[0];
if (den != 0) return 0;
if (v1[0] == 0 and v1[1] == 0 and v1[2] != 0) return 0;
if (v2[0] == 0 and v2[1] == 0 and v2[2] != 0) return 0;
return 2;
}
bool solve(int xa, int ya, int xb, int yb, int xc, int yc) {
vector<long long> v1(3), v2(3);
v1[0] = xc, v1[1] = -yc, v1[2] = xb - xa;
v2[0] = yc, v2[1] = xc, v2[2] = yb - ya;
long long t, u;
int k = solve_le(t, u, v1, v2);
if (k == 2) return 1;
if (k == 0) return 0;
if (t * v1[0] + u * v1[1] == v1[2] and t * v2[0] + u * v2[1] == v2[2])
return 1;
return 0;
}
int main() {
int i, j, k, tcc;
int tc = inf;
for (tcc = 0; tcc < tc; tcc++) {
int xa = getint(), ya = getint();
int xb = getint(), yb = getint();
int xc = getint(), yc = getint();
int x = xa, y = ya;
bool res = 0;
res = res or solve(x, y, xb, yb, xc, yc);
rot90(x, y, x, y);
res = res or solve(x, y, xb, yb, xc, yc);
rot90(x, y, x, y);
res = res or solve(x, y, xb, yb, xc, yc);
rot90(x, y, x, y);
res = res or solve(x, y, xb, yb, xc, yc);
rot90(x, y, x, y);
res = res or solve(x, y, xb, yb, xc, yc);
rot90(x, y, x, y);
if (res)
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <bits/stdc++.h>
long long a, b, c, d, e, f, i = 4, r, z, x, y;
int main() {
std::cin >> a >> b >> c >> d >> e >> f;
for (z = f * f + e * e; i--; x = c - a, y = d - (b = -b),
r |= (!z && !x && !y) | (z && !((x * e + y * f) % z) &&
!((y * e - x * f) % z)))
std::swap(a, b);
puts(r ? "YES" : "NO");
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
void check(long long axx, long long ayy) {
if (cx == 0 && cy == 0) {
if (axx - bx == 0 && ayy - by == 0) {
cout << "YES";
exit(0);
} else
return;
}
if ((cx * (by - ayy) - cy * (bx - axx)) % (cx * cx + cy * cy) != 0 ||
(cx * (bx - axx) + cy * (by - ayy)) % (cx * cx + cy * cy) != 0)
return;
cout << "YES";
exit(0);
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
check(ax, ay);
check(ay, -ax);
check(-ax, -ay);
check(-ay, ax);
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
bool estimate(long long vx, long long vy) {
long long r = cx * cx + cy * cy;
if (r == 0) return (vx == 0 and vy == 0);
return (vx * cx + vy * cy) % r == 0 and (cx * vy - cy * vx) % r == 0;
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
if (estimate(bx - ax, by - ay) or estimate(bx + ax, by + ay) or
estimate(bx + ay, by - ax) or estimate(bx - ay, by + ax))
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
void check(long long xx, long long yy) {
if (cx == 0 && cy == 0) {
if (xx == 0 && yy == 0) {
cout << "YES";
exit(0);
} else
return;
}
if ((cx * (yy)-cy * (xx)) % (cx * cx + cy * cy) != 0 ||
(cx * (xx) + cy * (yy)) % (cx * cx + cy * cy) != 0)
return;
cout << "YES";
exit(0);
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
check(bx - ax, by - ay);
check(bx - ay, by + ax);
check(bx + ax, by + ay);
check(bx + ay, by - ax);
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
int T;
long long xa, xb, xc, ya, yb, yc;
long long dx, dy;
bool gao(long long xc, long long yc) {
if (xc == 0 && yc == 0) return false;
return (dx * xc + dy * yc) % (xc * xc + yc * yc) == 0;
}
bool check(long long xa, long long ya) {
dx = xb - xa;
dy = yb - ya;
if (dx == 0 && dy == 0) return true;
return gao(xc, yc) && gao(-yc, xc);
}
bool judge() {
if (check(xa, ya)) return true;
if (check(-ya, xa)) return true;
if (check(-xa, -ya)) return true;
if (check(ya, -xa)) return true;
return false;
}
int main() {
scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &xa, &ya, &xb, &yb, &xc, &yc);
printf("%s\n", judge() ? "YES" : "NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long ax, ay, bx, by, cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
long long abs = cx * cx + cy * cy;
for (int i = 0; i < (4); i++) {
long long dx = ax - bx, dy = ay - by;
if (dx == 0 && dy == 0) {
cout << "YES";
return 0;
}
if (abs != 0) {
if (((dx * cx + dy * cy) % abs == 0) &&
((-dx * cy + dy * cx) % abs == 0)) {
cout << "YES";
return 0;
}
}
ay = -ay;
swap(ax, ay);
}
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long Det(long long a11, long long a12, long long a21, long long a22) {
return a11 * a22 - a12 * a21;
}
bool HasSolution(long long Ax, long long Ay, long long Bx, long long By,
long long Cx, long long Cy) {
long long d = Det(Cx, Cy, Cy, -Cx);
long long d1 = Det(Bx - Ax, Cy, By - Ay, -Cx);
long long d2 = Det(Cx, Bx - Ax, Cy, By - Ay);
if (d != 0) return d1 % d == 0 && d2 % d == 0;
return Ax == Bx && Ay == By;
}
int main() {
int Ax, Ay, Bx, By, Cx, Cy;
cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;
bool t = HasSolution(Ax, Ay, Bx, By, Cx, Cy) ||
HasSolution(Ay, -Ax, Bx, By, Cx, Cy) ||
HasSolution(-Ax, -Ay, Bx, By, Cx, Cy) ||
HasSolution(-Ay, Ax, Bx, By, Cx, Cy);
cout << (t ? "YES" : "NO") << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long X1, Y1;
long long A, B;
long long x, y;
int main() {
while (cin >> X1 >> Y1) {
cin >> A >> B >> x >> y;
string res = "NO";
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (x == 0 && y == 0) {
if (X1 == A && Y1 == B) res = "YES";
} else {
bool good = true;
long long c1 = A - X1;
long long c2 = B - Y1;
long long soor = c1 * x + c2 * y;
long long makh = x * x + y * y;
if (soor % makh) good = false;
long long a = soor / makh;
if (y == 0) {
soor = c2;
makh = -x;
} else {
soor = c1 - a * x;
makh = y;
}
if (soor % makh) good = false;
long long b = soor / makh;
if (good) {
res = "YES";
}
}
swap(A, B);
A *= -1;
}
swap(X1, Y1);
X1 *= -1;
}
cout << res << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int Ax, Ay, Bx, By, Cx, Cy;
cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;
for (int i = 0; i < 4; i++) {
int tx = -Ay, ty = Ax;
Ax = tx;
Ay = ty;
if (Ax == Bx && Ay == By) {
cout << "YES\n";
return 0;
}
double Dx = Bx - Ax;
double Dy = By - Ay;
double X = Cx;
double Y = Cy;
auto T = complex<double>(Dx, Dy) / complex<double>(X, Y);
if (abs(T.real() - round(T.real())) < 1e-12)
if (abs(T.imag() - round(T.imag())) < 1e-12) {
cout << "YES\n";
return 0;
}
}
cout << "NO\n";
}
|
#include <bits/stdc++.h>
using namespace std;
template <class TT>
TT abs(TT a) {
if (a < 0) return -a;
return a;
}
template <class ZZ>
ZZ max(ZZ a, ZZ b, ZZ c) {
return max(a, max(b, c));
}
template <class ZZ>
ZZ min(ZZ a, ZZ b, ZZ c) {
return min(a, min(b, c));
}
template <class ZZ>
ZZ sqr(ZZ a) {
return a * a;
}
typedef struct {
long long x, y;
} P;
P a, b, c;
bool f() {
P o = (P){b.x - a.x, b.y - a.y};
long long d = sqr(c.x) + sqr(c.y);
long long u = o.x * c.y - o.y * c.x;
if (!d) return !(o.x || o.y);
if (u % d) return false;
long long m = u / d;
if (c.x) return ((o.x - m * c.y) % c.x == 0);
if (c.y) return ((o.y + m * c.x) % c.y == 0);
return true;
}
int main() {
int i, k;
P d;
while (cin >> a.x >> a.y) {
cin >> b.x >> b.y;
cin >> c.x >> c.y;
k = 1;
for (i = 0; i < 4 && k; i++) {
if (f()) {
cout << "YES" << endl;
k = 0;
}
d.x = -a.y;
d.y = a.x;
a = d;
}
if (k) cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long Det(long long a11, long long a12, long long a21, long long a22) {
return a11 * a22 - a12 * a21;
}
bool HasSolution(long long Ax, long long Ay, long long Bx, long long By,
long long Cx, long long Cy) {
long long d = Det(Cx, Cy, Cy, -Cx);
long long d1 = Det(Bx - Ax, Cy, By - Ay, -Cx);
long long d2 = Det(Cx, Bx - Ax, Cy, By - Ay);
if (d != 0) return d1 % d == 0 && d2 % d == 0;
return Ax == Bx && Ay == By;
}
int main() {
int Ax, Ay, Bx, By, Cx, Cy;
cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;
bool t = HasSolution(Ax, Ay, Bx, By, Cx, Cy) ||
HasSolution(Ay, -Ax, Bx, By, Cx, Cy) ||
HasSolution(-Ax, -Ay, Bx, By, Cx, Cy) ||
HasSolution(-Ay, Ax, Bx, By, Cx, Cy);
cout << (t ? "YES" : "NO") << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long Ax, Ay, Bx, By, x, y;
long long tmpAx, tmpAy;
bool mod(long long opa, long long opb) {
if (opa % opb) return false;
return true;
}
bool check2() {
long long A = tmpAx, B = tmpAy;
long long tmp = A * y - B * x, op = y * y + x * x;
long long tmp1 = A * x + B * y, op1 = x * x + y * y;
if (op == 0) return A == 0 && B == 0;
if (tmp % op == 0 && tmp1 % op1 == 0) return true;
return false;
}
bool check() {
tmpAx = Ax - Bx;
tmpAy = Ay - By;
if (check2()) return true;
tmpAx = Ax + Bx;
tmpAy = Ay + By;
if (check2()) return true;
tmpAx = Ax - By;
tmpAy = Ay + Bx;
if (check2()) return true;
tmpAx = Ax + By;
tmpAy = Ay - Bx;
if (check2()) return true;
return false;
}
int main() {
scanf("%I64d%I64d", &Ax, &Ay);
scanf("%I64d%I64d", &Bx, &By);
scanf("%I64d%I64d", &x, &y);
if (check())
printf("YES");
else
printf("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x1, y1, x2, y2, x3, y3;
scanf("%I64d%I64d", &x1, &y1);
scanf("%I64d%I64d", &x2, &y2);
scanf("%I64d%I64d", &x3, &y3);
bool flag = false, flag2 = false, flag3 = false, flag4 = false;
long long m = x2 - x1, n = y2 - y1;
if (x3 == 0 && y3 == 0) {
if (m == 0 && n == 0)
flag = true;
else
flag = false;
} else {
long long a = x3 * x3, b = y3 * y3;
if ((y3 * m - x3 * n) % (a + b) == 0 && (x3 * m + y3 * n) % (a + b) == 0)
flag = true;
else
flag = false;
}
m = x2 + y1, n = y2 - x1;
if (x3 == 0 && y3 == 0) {
if (m == 0 && n == 0)
flag2 = true;
else
flag2 = false;
} else {
long long a = x3 * x3, b = y3 * y3;
if ((y3 * m - x3 * n) % (a + b) == 0 && (x3 * m + y3 * n) % (a + b) == 0)
flag2 = true;
else
flag2 = false;
}
m = x2 + x1, n = y2 + y1;
if (x3 == 0 && y3 == 0) {
if (m == 0 && n == 0)
flag3 = true;
else
flag3 = false;
} else {
long long a = x3 * x3, b = y3 * y3;
if ((y3 * m - x3 * n) % (a + b) == 0 && (x3 * m + y3 * n) % (a + b) == 0)
flag3 = true;
else
flag3 = false;
}
m = x2 - y1, n = y2 + x1;
if (x3 == 0 && y3 == 0) {
if (m == 0 && n == 0)
flag4 = true;
else
flag4 = false;
} else {
long long a = x3 * x3, b = y3 * y3;
if ((y3 * m - x3 * n) % (a + b) == 0 && (x3 * m + y3 * n) % (a + b) == 0)
flag4 = true;
else
flag4 = false;
}
flag || flag2 || flag3 || flag4 ? printf("YES\n") : printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool valid(long long num, long long den) {
if (den == 0) {
return num == 0;
} else {
return (num % den) == 0;
}
}
long long gcd(long long a, long long b) {
if (b == 0) {
return a;
} else {
return gcd(b, a % b);
}
}
bool valid(long long a, long long b, long long c) {
if (a == 0 && b == 0) {
return c == 0;
}
if (a < 0) {
a = -a;
}
if (b < 0) {
b = -b;
}
return c % gcd(a, b) == 0;
}
int main() {
long long ax, ay, bx, by, cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
long long a_x = -ay, a_y = ax;
long long c_x = -cy, c_y = cx;
for (long long a = -1; a <= 1; ++a) {
for (long long a_ = -1; a_ <= 1; ++a_) {
if (abs(a) + abs(a_) == 1) {
long long X = bx - a * ax - a_ * a_x;
long long Y = by - a * ay - a_ * a_y;
long long num1 = X * c_y - Y * c_x;
long long den1 = cx * c_y - cy * c_x;
long long num2 = X * cy - Y * cx;
long long den2 = c_x * cy - c_y * cx;
bool ok;
if (den1 != 0 && den2 != 0) {
ok = (num1 % den1) == 0 && (num2 % den2) == 0;
} else {
if (cx == 0 && c_x == 0) {
ok = X == 0 && valid(cy, c_y, Y);
} else if (cy == 0 && c_y == 0) {
ok = Y == 0 && valid(cx, c_x, X);
} else {
if (cx == 0) {
ok = (X % c_x) == 0 && (Y % c_y) == 0 && X / c_x == Y / c_y;
} else if (c_x == 0) {
ok = (X % cx) == 0 && (Y % cy) == 0 && X / cx == Y / cy;
} else {
ok = valid(cx, c_x, X) && X * cy == Y * cx;
}
}
}
if (ok) {
cout << "YES" << endl;
return 0;
}
}
}
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Point {
long long x, y;
Point() {}
Point(long long x, long long y) : x(x), y(y) {}
Point(const Point &p) : x(p.x), y(p.y) {}
Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
bool operator==(const Point &p) const { return (x == p.x && y == p.y); }
};
long long dot(Point p, Point q) { return p.x * q.x + p.y * q.y; }
long long cross(Point p, Point q) { return p.x * q.y - p.y * q.x; }
long long abs2(Point p) { return p.x * p.x + p.y * p.y; }
istream &operator>>(istream &is, Point &p) {
is >> p.x >> p.y;
return is;
}
ostream &operator<<(ostream &os, const Point &p) {
return os << "(" << p.x << ", " << p.y << ") ";
}
Point RotateCW90(Point p) { return Point(p.y, -p.x); }
bool check(Point A, Point B, Point C) {
long long det = abs2(C);
if (det == 0) {
return (A == B);
}
long long X = cross(B, C) - cross(A, C);
long long Y = dot(B, C) - dot(A, C);
return (X % det == 0 && Y % det == 0);
}
void run_case() {
Point A, B, C;
cin >> A >> B >> C;
for (long long i = 0; i < 4; i++) {
if (check(A, B, C)) {
cout << "YES\n";
return;
}
A = RotateCW90(A);
}
cout << "NO\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long T = 1;
for (long long t = 1; t <= T; t++) {
run_case();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
for (int i = 0; i < 4; ++i) {
long long cc = cx * cx + cy * cy;
long long vec1 = (bx - ax) * cx + (by - ay) * cy;
long long vec2 = (bx - ax) * (-cy) + (by - ay) * cx;
if (cc == 0) {
if (ax == bx && ay == by) {
cout << "YES" << endl;
return 0;
}
} else if (vec1 % cc == 0 && vec2 % cc == 0) {
cout << "YES" << endl;
return 0;
}
long long t = ay;
ay = ax;
ax = -t;
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a1, a2, b1, b2, c1, c2;
void rec(long long p, long long q) {
long long mod = c1 * c1 + c2 * c2;
if ((p * c1 + q * c2) % mod == 0 && (q * c1 - p * c2) % mod == 0) {
puts("YES");
exit(0);
}
}
int main() {
scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &a1, &a2, &b1, &b2, &c1, &c2);
if (c1 == 0 && c2 == 0) {
if ((a1 == b1 && a2 == b2) || (a1 == -b1 && a2 == -b2) ||
(a1 == b2 && a2 == -b1) || (a1 == -b2 && a2 == b1))
puts("YES");
else
puts("NO");
return 0;
}
rec(b1 - a1, b2 - a2);
rec(b1 + a1, b2 + a2);
rec(b1 + a2, b2 - a1);
rec(b1 - a2, b2 + a1);
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
return x > 0 ? x : (-x);
}
template <class T>
T sqr(T x) {
return x * x;
}
long long x3982098543, y3982098543, x2, y2, x3, y3;
bool check(long long X, long long Y) {
long long d = sqr(x3) + sqr(y3);
long long dx = X * x3 + Y * y3;
long long dy = x3 * Y - y3 * X;
if (d == 0) {
if (dx == 0 && dy == 0 && X == 0 && Y == 0)
return true;
else
return false;
} else {
if (dx % d == 0 && dy % d == 0)
return true;
else
return false;
}
}
int main() {
cin >> x3982098543 >> y3982098543 >> x2 >> y2 >> x3 >> y3;
for (int it = 0; it < 8; ++it) {
long long X = x2 - x3982098543, Y = y2 - y3982098543;
if (check(X, Y)) {
printf("YES\n");
return 0;
}
long long x = y3982098543, y = -x3982098543;
x3982098543 = x, y3982098543 = y;
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long A[2], B[2], C[2];
int check(long long p, long long q) {
long long a, b, c;
a = (-C[0] * p - C[1] * q);
b = (-C[1] * p + C[0] * q);
c = (C[0] * C[0] + C[1] * C[1]);
return (a % c == 0 && b % c == 0);
}
int check2() {
if (A[0] == B[0] && A[1] == B[1]) return 1;
if ((-1 * A[1]) == B[0] && A[0] == B[1]) return 1;
if ((-1 * A[0]) == B[0] && (-1 * A[1]) == B[1]) return 1;
if (A[1] == B[0] && (-1 * A[0]) == B[1]) return 1;
return 0;
}
int main(void) {
int i, T, j, m, n;
for (i = 0; i < 2; i++) scanf("%I64d", &A[i]);
for (i = 0; i < 2; i++) scanf("%I64d", &B[i]);
for (i = 0; i < 2; i++) scanf("%I64d", &C[i]);
if (C[0] == 0 && C[1] == 0) {
if (check2())
printf("YES\n");
else
printf("NO\n");
} else if (check(B[0] - A[0], B[1] - A[1]) ||
check(B[0] - A[1], B[1] + A[0]) ||
check(B[0] + A[0], B[1] + A[1]) || check(B[0] + A[1], B[1] - A[0]))
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void setIO(string s = "") {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin.exceptions(cin.failbit);
if (s.size()) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
}
long long int Ax, Ay;
long long int Bx, By, Cx, Cy;
void solve() {
long long int n, m, j, l, k, i;
cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;
for (i = 0; i < 4; i++) {
long long int dx = Bx - Ax;
long long int dy = By - Ay;
if (dx == 0 && dy == 0) {
cout << "YES";
cout << "\n";
return;
}
long long int u = dx * Cx + dy * Cy;
long long int v = dx * Cy - dy * Cx;
long long int w = Cx * Cx + Cy * Cy;
if (w != 0 && u % w == 0 && v % w == 0) {
cout << "YES";
cout << "\n";
return;
}
Ax *= -1;
swap(Ax, Ay);
}
cout << "NO";
cout << "\n";
return;
}
int main() {
setIO();
long long int totalTestCase = 1;
for (long long int testCase = 1; testCase <= totalTestCase; testCase++) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ax, ay, bx, by, cx, cy;
inline bool isok(int ex, int ey) {
if (cx == 0 && cy == 0) return ex == 0 && ey == 0;
long long a = 1ll * ex * cx + 1ll * ey * cy,
b = 1ll * ey * cx - 1ll * ex * cy,
c = 1ll * cx * cx + 1ll * cy * cy;
return a % c == 0 && b % c == 0;
}
int main() {
scanf("%d%d%d%d%d%d", &ax, &ay, &bx, &by, &cx, &cy);
if (isok(bx - ax, by - ay) || isok(bx + ay, by - ax) ||
isok(bx + ax, by + ay) || isok(bx - ay, by + ax))
printf("YES");
else
printf("NO");
}
|
#include <bits/stdc++.h>
int main() {
long long a1, a2, b1, b2, c1, c2, D;
scanf("%lld%lld%lld%lld%lld%lld", &a1, &a2, &b1, &b2, &c1, &c2);
if (c1 == 0 && c2 == 0) {
if ((a1 == b1 && a2 == b2) || (a1 == -b1 && a2 == -b2) ||
(a1 == b2 && a2 == -b1) || (a1 == -b2 && a2 == b1))
printf("YES\n");
else
printf("NO\n");
return 0;
}
D = c1 * c1 + c2 * c2;
long long b1a1 = b1 + a1, b1_a1 = b1 - a1, b1a2 = b1 + a2, b1_a2 = b1 - a2,
b2a2 = b2 + a2, b2_a2 = b2 - a2, b2a1 = b2 + a1, b2_a1 = b2 - a1;
if (((((b1a1)*c1 + (b2a2)*c2) % D) || (((b1a1)*c2 - (b2a2)*c1) % D)) &&
((((b1_a1)*c1 + (b2_a2)*c2) % D) || (((b1_a1)*c2 - (b2_a2)*c1) % D)) &&
((((b1_a2)*c1 + (b2a1)*c2) % D) || (((b1_a2)*c2 - (b2a1)*c1) % D)) &&
((((b1a2)*c1 + (b2_a1)*c2) % D) || (((b1a2)*c2 - (b2_a1)*c1) % D)))
printf("NO\n");
else
printf("YES\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy, dx, dy;
long long a1, b1, c1, a2, b2, c2, d;
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
for (int i = 0; i < 4; i++, swap(ax, ay), ax = -ax) {
dx = bx - ax;
dy = by - ay;
a1 = cx;
b1 = cy;
c1 = -dx;
a2 = cy;
b2 = -cx;
c2 = -dy;
d = a1 * b2 - a2 * b1;
if (dx * dx + dy * dy == 0 ||
d && (b1 * c2 - b2 * c1) % d == 0 && (c1 * a2 - c2 * a1) % d == 0) {
puts("YES");
return 0;
}
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool solve(long long A, long long B, long long C, long long D, long long E,
long long F) {
return (C * E - B * F) % (A * E - B * D) == 0 &&
(C * D - A * F) % (B * D - A * E) == 0;
}
int main() {
long long x[3], y[3];
for (int i = 0; i < 3; i++) scanf("%I64d%I64d", x + i, y + i);
if (!x[2] && !y[2]) {
for (int i = 0; i < 4; i++) {
if (x[0] == x[1] && y[0] == y[1]) return puts("YES");
swap(x[0], y[0] *= -1);
}
return puts("NO");
}
for (int i = 0; i < 4; i++) {
if (solve(-y[2], x[2], x[1] - x[0], x[2], y[2], y[1] - y[0]))
return puts("YES");
swap(x[0], y[0] *= -1);
}
puts("NO");
}
|
#include <bits/stdc++.h>
int main() {
std::ios_base::sync_with_stdio(false);
int64_t a1, a2, b1, b2, c1, c2, D, m[4], n[4];
std::cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
if (c1 == 0 && c2 == 0) {
if ((a1 == b1 && a2 == b2) || (a1 == -b1 && a2 == -b2) ||
(a1 == b2 && a2 == -b1) || (a1 == -b2 && a2 == b1))
std::cout << "YES" << std::endl;
else
std::cout << "NO" << std::endl;
return 0;
}
D = c1 * c1 + c2 * c2;
m[0] = (b1 + a1) * c1 + (b2 + a2) * c2;
n[0] = (b1 + a1) * c2 - (b2 + a2) * c1;
m[1] = (b1 - a1) * c1 + (b2 - a2) * c2;
n[1] = (b1 - a1) * c2 - (b2 - a2) * c1;
m[2] = (b1 - a2) * c1 + (b2 + a1) * c2;
n[2] = (b1 - a2) * c2 - (b2 + a1) * c1;
m[3] = (b1 + a2) * c1 + (b2 - a1) * c2;
n[3] = (b1 + a2) * c2 - (b2 - a1) * c1;
bool ok = false;
for (int i = 0; i != 4; ++i) ok |= !((m[i] % D) || (n[i] % D));
std::cout << (ok ? "YES" : "NO") << std::endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void good() {
printf("YES\n");
exit(0);
}
long long A[3][2];
int main() {
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 2; ++j) scanf("%lld", &A[i][j]);
swap(A[1][0], A[2][0]);
swap(A[1][1], A[2][1]);
for (int i = 0; i < 4; ++i) {
long long int y = A[0][1];
long long int x = A[0][0];
A[0][0] = y;
A[0][1] = -x;
long long k = A[2][0] - A[0][0];
long long q = A[2][1] - A[0][1];
long long tt = A[1][0] * A[1][0] + A[1][1] * A[1][1];
if (tt != 0) {
bool f1 = (A[1][0] * k + A[1][1] * q) % tt == 0;
bool f2 = (A[1][1] * k - A[1][0] * q) % tt == 0;
if (f1 && f2) good();
} else {
if (k == 0 && q == 0) good();
}
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long xA, yA, xB, yB, xC, yC, temp;
int main() {
cin >> xA >> yA >> xB >> yB >> xC >> yC;
for (int i = 0; i < 4; ++i) {
long long xD = xB - xA, yD = yB - yA;
if (xD == 0 && yD == 0) {
cout << "YES" << endl;
return 0;
}
long long n1 = xC * xD + yC * yD;
long long n2 = -yC * xD + xC * yD;
long long n3 = xC * xC + yC * yC;
if (n3 > 0 && n1 % n3 == 0 && n2 % n3 == 0) {
cout << "YES" << endl;
return 0;
}
temp = xA;
xA = -yA;
yA = temp;
}
cout << "NO" << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
bool check(long long ax, long long ay, long long bx, long long by, long long cx,
long long cy) {
long long tx = bx - ax, ty = by - ay;
if (cx == 0 && cy == 0) return (tx == 0 && ty == 0);
long long dx = cy, dy = -cx;
long long a = (tx * dy - dx * ty) / (cx * dy - dx * cy);
long long b = (tx * cy - cx * ty) / (dx * cy - cx * dy);
if (a * cx + b * dx != tx) return false;
if (a * cy + b * dy != ty) return false;
return true;
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
bool flag = false;
if (check(ax, ay, bx, by, cx, cy)) flag = true;
if (check(ay, -ax, bx, by, cx, cy)) flag = true;
if (check(-ax, -ay, bx, by, cx, cy)) flag = true;
if (check(-ay, ax, bx, by, cx, cy)) flag = true;
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
struct P {
long long x, y;
P() {}
P(long long x, long long y) : x(x), y(y) {}
P rotate() { return P(-y, x); }
P operator-(const P& rhs) const { return P(x - rhs.x, y - rhs.y); }
long long operator*(const P& rhs) const { return x * rhs.x + y * rhs.y; }
bool operator==(const P& rhs) const { return x == rhs.x && y == rhs.y; }
};
bool judge(P& u, P& v) {
if (v == P(0, 0)) return u == P(0, 0);
long long w = v.x * v.x + v.y * v.y;
return u * v % w == 0 && u * v.rotate() % w == 0;
}
P a, b, c;
int main() {
ios_base::sync_with_stdio(0);
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y) {
bool ok = false;
for (int i = 0; i < 4; ++i) {
P d = b - a;
if (judge(d, c)) {
ok = true;
break;
}
a = a.rotate();
}
cout << (ok ? "YES" : "NO") << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long a, b, c, d, e, f, k;
bool check(long long x, long long y) {
if (k == 0) {
return x == c && y == d;
}
return ((c - x) * e + (d - y) * f) % k == 0 &&
(e * (d - y) + f * (x - c)) % k == 0;
}
int main() {
while (cin >> a >> b >> c >> d >> e >> f) {
k = e * e + f * f;
if (check(a, b) || check(-a, -b) || check(b, -a) || check(-b, a)) {
cout << "YES" << endl;
} else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
long long AX[4], AY[4], CX[4], CY[4];
long long GCD(long long a, long long b) {
a = abs(a), b = abs(b);
if (a < b) swap(a, b);
return b ? GCD(b, a % b) : a;
}
bool judge(long long ax, long long ay, long long cx, long long cy) {
if (cx == 0 && cy == 0) return ax == bx && ay == by;
if (cx == 0) return (bx - ax) % cy == 0 && (by - ay) % cy == 0;
if (cy == 0) return (bx - ax) % cx == 0 && (by - ay) % cx == 0;
long long gcd = GCD(abs(cx), abs(cy));
long long gcd1 = GCD(gcd, abs(bx - ax));
long long gcd2 = GCD(gcd, abs(by - ay));
if (gcd != gcd1 || gcd != gcd2) return 0;
long long zi1 = abs((bx - ax) * cx + (by - ay) * cy);
long long zi2 = abs(cx * (by - ay) - cy * (bx - ax));
long long mu = abs(cx * cx + cy * cy);
if (mu)
if (zi1 % mu || zi2 % mu) return 0;
if (!mu && (zi1 || zi2)) return 0;
return 1;
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
AX[0] = ax, AY[0] = ay;
AX[1] = -ay, AY[1] = ax;
AX[2] = -ax, AY[2] = -ay;
AX[3] = ay, AY[3] = -ax;
CX[0] = cx, CY[0] = cy;
CX[1] = -cy, CY[1] = cx;
CX[2] = -cx, CY[2] = -cy;
CX[3] = cy, CY[3] = -cx;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (judge(AX[i], AY[i], CX[j], CY[j])) return cout << "YES", 0;
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
int ni() {
int a;
scanf("%d", &a);
return a;
}
double nf() {
double a;
scanf("%lf", &a);
return a;
}
char sbuf[100005];
string ns() {
scanf("%s", sbuf);
return sbuf;
}
long long nll() {
long long a;
scanf("%lld", &a);
return a;
}
template <class T>
void out(T a, T b) {
bool first = true;
for (T i = a; i != b; ++i) {
if (!first) printf(" ");
first = false;
cout << *i;
}
printf("\n");
}
template <class T>
void outl(T a, T b) {
for (T i = a; i != b; ++i) {
cout << *i << "\n";
}
}
int n, m;
bool moo(long long cx, long long cy, long long x, long long y) {
if ((x * cx + y * cy) % (cx * cx + cy * cy) != 0) return false;
if ((y * cx - x * cy) % (cx * cx + cy * cy) != 0) return false;
return true;
}
int main() {
int i, j, k;
int x = ni();
int y = ni();
int tx = ni();
int ty = ni();
int cx = ni();
int cy = ni();
if (cx == 0 && cy == 0) {
for (i = (0); i < (((4))); ++i) {
if (x == tx && y == ty) {
printf("YES\n");
return 0;
}
swap(x, y);
x = -x;
}
printf("NO\n");
return 0;
}
for (i = (0); i < (((4))); ++i) {
if (moo(cx, cy, tx - x, ty - y)) {
printf("YES\n");
return 0;
}
swap(x, y);
x = -x;
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long A, B, c, d, E, F;
int read();
bool zc(long long fz, long long fm) { return !(fz % fm); }
bool ask(long long a, long long b, long long e, long long f) {
if (!e && !f) return a == c & b == d;
if (!e) return zc(c - a, f) & zc(d - b, f);
if (!f) return zc(c - a, e) & zc(d - b, e);
long long fx = e * (c - a) + f * (d - b);
long long fy = f * (c - a) + e * (b - d);
long long fm = e * e + f * f;
fx = fx < 0 ? -fx : fx;
fy = fy < 0 ? -fy : fy;
return zc(fx, fm) & zc(fy, fm);
}
int main() {
A = read(), B = read(), c = read();
d = read(), E = read(), F = read();
if (ask(A, B, E, F))
return puts("YES"), 0;
else if (ask(A, B, -F, E))
return puts("YES"), 0;
else if (ask(A, B, F, -E))
return puts("YES"), 0;
else if (ask(A, B, -E, -F))
return puts("YES"), 0;
else if (ask(-B, A, E, F))
return puts("YES"), 0;
else if (ask(-B, A, -F, E))
return puts("YES"), 0;
else if (ask(-B, A, F, -E))
return puts("YES"), 0;
else if (ask(-B, A, -E, -F))
return puts("YES"), 0;
else if (ask(B, -A, E, F))
return puts("YES"), 0;
else if (ask(B, -A, -F, E))
return puts("YES"), 0;
else if (ask(B, -A, F, -E))
return puts("YES"), 0;
else if (ask(B, -A, -E, -F))
return puts("YES"), 0;
else if (ask(-A, -B, E, F))
return puts("YES"), 0;
else if (ask(-A, -B, -F, E))
return puts("YES"), 0;
else if (ask(-A, -B, F, -E))
return puts("YES"), 0;
else if (ask(-A, -B, -E, -F))
return puts("YES"), 0;
else
puts("NO");
return 0;
}
int read() {
int x = 0, f = 1;
char c = getchar();
while (c > '9' || c < '0') f = (c == '-') ? -1 : f, c = getchar();
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
|
#include <bits/stdc++.h>
bool check(long long cx, long long cy, long long dx, long long dy) {
long long t = cx * cx + cy * cy;
long long a = -cy * dy - cx * dx;
long long b = cx * dy - dx * cy;
return t != 0 && a % t == 0 && b % t == 0;
}
int main() {
int x1, y1, x2, y2, x3, y3;
scanf("%d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3);
if (x3 == 0 && y3 == 0) {
if (x1 == x2 && y1 == y2)
printf("YES\n");
else if (x1 == -y2 && y1 == x2)
printf("YES\n");
else if (x1 == -x2 && y1 == -y2)
printf("YES\n");
else if (x1 == y2 && y1 == -x2)
printf("YES\n");
else
printf("NO\n");
return 0;
}
bool ans = check(x3, y3, x1 + x2, y1 + y2) ||
check(x3, y3, x1 - y2, y1 + x2) ||
check(x3, y3, x1 - x2, y1 - y2) || check(x3, y3, x1 + y2, y1 - x2);
if (ans)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60000000")
using namespace std;
const long double eps = 1e-10;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T first) {
return first * first;
}
pair<long long, long long> A, B, C;
pair<long long, long long> operator-(pair<long long, long long> p1,
pair<long long, long long> p2) {
return pair<long long, long long>(p1.first - p2.first, p1.second - p2.second);
}
pair<long long, long long> rotate(pair<long long, long long> first) {
return pair<long long, long long>(-first.second, first.first);
}
pair<long double, long double> rotate(pair<long double, long double> p,
long double ang) {
return pair<long double, long double>(
p.first * cosl(ang) - p.second * sinl(ang),
p.first * sinl(ang) + p.second * cosl(ang));
}
bool integer(long double first) {
long double X = floorl(first + 0.1);
if (fabsl(first - X) < eps) return 1;
return 0;
}
bool check(pair<long long, long long> A, pair<long long, long long> B) {
if (B == pair<long long, long long>(0, 0)) return 1;
if (A == pair<long long, long long>(0, 0)) return 0;
pair<long double, long double> a =
pair<long double, long double>(A.first, A.second);
long double ang = atan2l(a.second, a.first);
long double d = sqrtl((long double)(A.first * A.first + A.second * A.second));
pair<long double, long double> b =
rotate(pair<long double, long double>(B.first, B.second), -ang);
b.first /= d;
b.second /= d;
b.first = fabsl(b.first);
b.second = fabsl(b.second);
if (integer(b.first) && integer(b.second)) return 1;
return 0;
}
int main() {
cin >> A.first >> A.second;
cin >> B.first >> B.second;
cin >> C.first >> C.second;
for (int i = 0; i < (int)(4); i++) {
pair<long long, long long> D = B - A;
if (check(C, D)) {
cout << "YES\n";
return 0;
}
A = rotate(A);
}
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class T>
void pv(T a, T b) {
for (T i = a; i != b; ++i) cout << *i << " ";
cout << endl;
}
long long f(long long x) { return max(x, -x); }
int solve(long long x, long long y, long long x_, long long y_, long long a,
long long b) {
long long dx = x_ - x;
long long dy = y_ - y;
if (a == 0 && b == 0) {
if (dx == 0 && dy == 0) return 1;
}
if (a == 0 && b != 0) {
if (f(dx) % f(b) == 0 && f(dy) % f(b) == 0) return 1;
}
if (a != 0 && b == 0) {
if (f(dx) % f(a) == 0 && f(dy) % f(a) == 0) return 1;
}
if (a != 0 && b != 0) {
long long det = a * a + b * b;
long long detA = a * dx + b * dy;
long long detB = b * dx - a * dy;
if (f(detA) % f(det) == 0 && f(detB) % f(det) == 0) return 1;
}
return 0;
}
void flip(long long &x, long long &y) {
long long nx = -y, ny = x;
x = nx, y = ny;
}
int main() {
long long x, y, x_, y_, a, b;
cin >> x >> y >> x_ >> y_ >> a >> b;
for (int i = 0; i < (10); i++) {
for (int j = 0; j < (10); j++) {
if (solve(x, y, x_, y_, a, b)) {
puts("YES");
return 0;
}
flip(x_, y_);
}
flip(x, y);
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
long long a, b, c, d, e, f, i = 4, r, z, x, y;
int main() {
std::cin >> a >> b >> c >> d >> e >> f;
for (z = f * f + e * e; i--; x = c - a, y = d - (b = -b),
r |= (!z && !x && !y) | (z && !((x * e + y * f) % z) &&
!((y * e - x * f) % z)))
std::swap(a, b);
puts(r ? "YES" : "NO");
}
|
#include <bits/stdc++.h>
using namespace std;
int n, m;
int k;
bool debug = false;
long long xa, xb, xc, ya, yb, yc;
long long X[5], Y[5];
long long d[4][2][2] = {
{{1, 0}, {0, 1}}, {{-1, 0}, {0, -1}}, {{0, 1}, {-1, 0}}, {{0, -1}, {1, 0}}};
bool dd(long long x2, long long y2) {
long long dx = xa - x2, dy = ya - y2;
long long t1 = -(xc * dx + yc * dy) / (xc * xc + yc * yc);
long long t2;
if (yc != 0) {
t2 = -(dx + xc * t1) / yc;
} else {
t2 = (dy + yc * t1) / xc;
}
return (xa + xc * t1 + yc * t2 == x2 && ya + yc * t1 - xc * t2 == y2);
}
int main() {
cin >> xa >> ya >> xb >> yb >> xc >> yc;
for (int i = 0; i < 4; i++) {
X[i] = d[i][0][0] * xb + d[i][0][1] * yb;
Y[i] = d[i][1][0] * xb + d[i][1][1] * yb;
}
if (xc == 0 && yc == 0) {
for (int i = 0; i < 4; i++) {
if (xa == X[i] && ya == Y[i]) {
puts("YES");
return 0;
}
}
} else {
for (int i = 0; i < 4; i++)
if (dd(X[i], Y[i])) {
puts("YES");
return 0;
}
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool check(int xa, int ya, int xb, int yb, long long xc, long long yc) {
long long k1 = xb - xa;
long long k2 = yb - ya;
if (xc != 0) {
long long wNum = k1 * yc - k2 * xc;
long long wDen = xc * xc + yc * yc;
if (wNum % wDen) return false;
long long w = wNum / wDen;
long long qNum = k1 - w * yc;
if (qNum % xc) return false;
return true;
} else {
return (k1 % yc == 0) && (k2 % yc == 0);
}
}
int main() {
ios_base::sync_with_stdio(false);
int xa, xb, xc, ya, yb, yc;
cin >> xa >> ya >> xb >> yb >> xc >> yc;
if (xc == 0 && yc == 0) {
if ((xa == xb && ya == yb) || (xa == -yb && ya == xb) ||
(xa == -xb && ya == -yb) || (xa == yb && ya == -xb))
cout << "YES";
else
cout << "NO";
return 0;
}
if (check(xa, ya, xb, yb, xc, yc) || check(ya, -xa, xb, yb, xc, yc) ||
check(-xa, -ya, xb, yb, xc, yc) || check(-ya, xa, xb, yb, xc, yc))
cout << "YES";
else
cout << "NO";
}
|
#include <bits/stdc++.h>
int main() {
int a1, a2, b1, b2, c1, c2;
scanf("%d%d%d%d%d%d", &a1, &a2, &b1, &b2, &c1, &c2);
if (c1 == 0 && c2 == 0) {
if ((a1 == b1 && a2 == b2) || (a1 == -b1 && a2 == -b2) ||
(a1 == b2 && a2 == -b1) || (a1 == -b2 && a2 == b1))
printf("YES\n");
else
printf("NO\n");
return 0;
}
long long D = (long long)(c1)*c1 + (long long)(c2)*c2;
int b1a1 = b1 + a1, b1_a1 = b1 - a1, b1a2 = b1 + a2, b1_a2 = b1 - a2,
b2a2 = b2 + a2, b2_a2 = b2 - a2, b2a1 = b2 + a1, b2_a1 = b2 - a1;
if (((((b1a1) * (long long)(c1) + (b2a2) * (long long)(c2)) % D) ||
(((b1a1) * (long long)(c2) - (b2a2) * (long long)(c1)) % D)) &&
((((b1_a1) * (long long)(c1) + (b2_a2) * (long long)(c2)) % D) ||
(((b1_a1) * (long long)(c2) - (b2_a2) * (long long)(c1)) % D)) &&
((((b1_a2) * (long long)(c1) + (b2a1) * (long long)(c2)) % D) ||
(((b1_a2) * (long long)(c2) - (b2a1) * (long long)(c1)) % D)) &&
((((b1a2) * (long long)(c1) + (b2_a1) * (long long)(c2)) % D) ||
(((b1a2) * (long long)(c2) - (b2_a1) * (long long)(c1)) % D)))
printf("NO\n");
else
printf("YES\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long x, y, ax, ay, bx, by, cx, cy, dx, dy, Cx, Cy;
int i, j, k, m, n;
while (cin >> ax >> ay >> bx >> by >> cx >> cy) {
for (i = 0; i < 4; i++) {
x = ay;
y = -ax;
ax = x;
ay = y;
dx = bx - ax;
dy = by - ay;
Cx = cy;
Cy = -cx;
if (cx || cy) {
if ((dx * cy - dy * cx) % (Cx * cy - Cy * cx) == 0 &&
(dx * Cy - dy * Cx) % (cx * Cy - cy * Cx) == 0) {
puts("YES");
break;
}
} else {
if (!dx && !dy) {
puts("YES");
break;
}
}
}
if (i == 4) puts("NO");
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
const long long N = 1e9 + 5, mod = 1e9 + 7;
struct pt {
long long x, y;
} A, B, C;
long long dist(pt a) { return a.x * a.x + a.y * a.y; }
long long cross(pt a, pt b) { return a.x * b.y - a.y * b.x; }
long long dot(pt a, pt b) { return a.x * b.x + a.y * b.y; }
bool chk() {
long long d = dist(C);
if (d == 0) return A.x == B.x && A.y == B.y;
pt tmp;
tmp.x = A.x + B.x;
tmp.y = A.y + B.y;
long long v1 = dot(tmp, C);
long long v2 = cross(tmp, C);
if (v1 % d != 0 || v2 % d != 0) return 0;
return 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
for (long long i = 0; i < 4; i++) {
if (chk()) return cout << "YES", 0;
swap(A.x, A.y);
A.y *= -1;
}
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
long long det(long long a11, long long a12, long long a21, long long a22) {
return a11 * a22 - a12 * a21;
}
bool can(long long ax, long long ay, long long bx, long long by, long long cx,
long long cy) {
long long dt = det(cy, -cx, cx, cy);
bx -= ax;
by -= ay;
if (dt == 0) {
if (!bx && !by) {
return true;
} else {
return false;
}
} else {
long long k = det(by, -cx, bx, cy);
long long l = det(cy, by, cx, bx);
if (k % dt == 0 && l % dt == 0) {
return true;
} else {
return false;
}
}
}
int main() {
long long ax, ay, bx, by, cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
if (can(ax, ay, bx, by, cx, cy) || can(ay, -ax, bx, by, cx, cy) ||
can(-ax, -ay, bx, by, cx, cy) || can(-ay, ax, bx, by, cx, cy)) {
puts("YES");
} else {
puts("NO");
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167177216")
using namespace std;
const int MAX = 2147483647;
const int MAXN = 200100;
const long long MOD = 1000000000 + 7;
vector<long long> t(MAXN, -2000000000);
long long n, k, b, c;
vector<long long> tmp(MAXN);
pair<bool, long long> check(int val) {
long long ans = 0;
int idx = 0;
bool inited = false;
for (int i = 0; i < n; ++i) {
if (t[i] > val) continue;
if (!inited && (n - i) < k) return make_pair(false, 1000000000000000000);
inited = true;
long long need = val - t[i];
long long cost;
if (5 * c <= b) {
cost = (long long)need * c;
} else {
cost = (need / (long long)5) * b + (need % (long long)5) * c;
}
tmp[idx++] = cost;
}
sort(tmp.begin(), tmp.begin() + idx);
for (int i = 0; i < k; ++i) {
ans += tmp[i];
}
return make_pair(true, ans);
}
int main(int argc, char* argv[]) {
long long ax, ay, bx, by, cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
long long dx = bx - ax;
long long dy = by - ay;
cx = cx;
cy = cy;
if (dx == cx && dy == cy || (dx == cy && dy == cx)) {
cout << "YES";
return 0;
}
long long D = cx * cx + cy * cy;
long long AD = dx * cx + dy * cy;
long long BD = cx * dy - cy * dx;
if (D != 0 && AD % D == 0 && BD % D == 0) {
cout << "YES";
return 0;
}
dx = bx + ay;
dy = by - ax;
cx = cx;
cy = cy;
if (dx == cx && dy == cy || (dx == cy && dy == cx)) {
cout << "YES";
return 0;
}
D = cx * cx + cy * cy;
AD = dx * cx + dy * cy;
BD = cx * dy - cy * dx;
if (D != 0 && AD % D == 0 && BD % D == 0) {
cout << "YES";
return 0;
}
dx = bx - ay;
dy = by + ax;
cx = cx;
cy = cy;
if (dx == cx && dy == cy || (dx == cy && dy == cx)) {
cout << "YES";
return 0;
}
D = cx * cx + cy * cy;
AD = dx * cx + dy * cy;
BD = cx * dy - cy * dx;
if (D != 0 && AD % D == 0 && BD % D == 0) {
cout << "YES";
return 0;
}
dx = bx + ax;
dy = by + ay;
cx = cx;
cy = cy;
if (dx == cx && dy == cy || (dx == cy && dy == cx)) {
cout << "YES";
return 0;
}
D = cx * cx + cy * cy;
AD = dx * cx + dy * cy;
BD = cx * dy - cy * dx;
if (D != 0 && AD % D == 0 && BD % D == 0) {
cout << "YES";
return 0;
}
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a1, a2, b1, b2, c1, c2;
long long flag = 0;
long long check(long long x, long long y) {
x -= b1, y -= b2;
long long dis = c1 * c1 + c2 * c2;
if (!dis) return !x && !y;
return !((c1 * x + c2 * y) % dis) && !((c1 * y - c2 * x) % dis);
}
signed main() {
cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
flag |= check(a1, a2);
flag |= check(-a1, -a2);
flag |= check(a2, -a1);
flag |= check(-a2, a1);
if (flag)
printf("YES");
else
printf("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long xa, ya, xb, yb, xc, yc, dx, dy, a, b, c;
cin >> xa >> ya;
cin >> xb >> yb;
cin >> xc >> yc;
for (int i = 0; i < 4; i++) {
dx = xb - xa, dy = yb - ya;
a = dx * xc + dy * yc;
b = dx * yc - dy * xc;
c = xc * xc + yc * yc;
if (dx == 0 && dy == 0) {
puts("YES");
return 0;
}
if (c != 0 && a % c == 0 && b % c == 0) {
puts("YES");
return 0;
}
xa = -xa;
swap(xa, ya);
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, m, n, d, e, f, a, c, b, t, s, g, h;
map<long long, long long> y, x;
string p;
int main() {
cin >> i >> j >> n >> m >> c >> d;
k = c * c + d * d;
if (k == 0) {
if (i == n && j == m) t = 1;
if (i == -n && j == -m) t = 1;
if (j == n && -i == m) t = 1;
if (-j == n && i == m) t = 1;
if (t == 1)
cout << "YES";
else
cout << "NO";
return 0;
}
a = n - i;
b = m - j;
e = a * c + b * d;
f = a * d - b * c;
if (e % k == 0 && f % k == 0) t = 1;
a = n + i;
b = m + j;
e = a * c + b * d;
f = a * d - b * c;
if (e % k == 0 && f % k == 0) t = 1;
a = n + j;
b = m - i;
e = a * c + b * d;
f = a * d - b * c;
if (e % k == 0 && f % k == 0) t = 1;
a = n - j;
b = m + i;
e = a * c + b * d;
f = a * d - b * c;
if (e % k == 0 && f % k == 0) t = 1;
if (t == 1)
cout << "YES";
else
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
int Ax, Ay, Bx, By, Cx, Cy;
long long det(int a, int b, int c, int d) {
return (long long)a * d - (long long)b * c;
}
int gcd(int a, int b) {
if (a == 0) return b;
if (b == 0) return a;
return gcd(b, a % b);
}
bool solve2(int a, int b, int c) {
if (a == 0 && b == 0) return c == 0;
if (a == 0) return c % b == 0 && c / b >= 0;
if (b == 0) return c % a == 0 && c / a >= 0;
int d = gcd(a, b), q;
if (c % d != 0) return false;
if (a < 0) {
c = -c;
b = -b;
}
if (b > 0)
for (q = 0; c - b * q >= 0; q++)
if ((c - q * b) % a == 0 && (c - q * b) / a >= 0)
return true;
else
return true;
return false;
}
bool solve(int a1, int b1, int c1, int a2, int b2, int c2) {
long long D = det(a1, b1, a2, b2), D1 = det(a1, c1, a2, c2),
D2 = det(c1, b1, c2, b2);
if (D) return (D1 % D == 0 && D2 % D == 0 && D1 / D >= 0 && D2 / D >= 0);
return solve2(a1, b1, c1);
}
bool go(int cx, int cy, int dx, int dy) {
return solve(cx, dx, Bx - Ax, cy, dy, By - Ay);
}
int main(int argc, char *argv[]) {
scanf("%d%d%d%d%d%d", &Ax, &Ay, &Bx, &By, &Cx, &Cy);
int i, j;
for (i = 0; i < 4; i++) {
swap(Ax, Ay);
Ax = -Ax;
if (Cx == 0 && Cy == 0) {
if (Ax == Bx && Ay == By) {
printf("YES\n");
return 0;
}
} else {
for (j = 0; j < 4; j++) {
swap(Cx, Cy);
Cx = -Cx;
if (go(Cx, Cy, -Cy, Cx)) {
printf("YES\n");
return 0;
}
}
}
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b, c, d, x, y;
cin >> a >> b >> c >> d >> x >> y;
long long x2[5], y2[5], cx = a, cy = b;
for (int i = 0; i < 4; i++) {
x2[i] = c - cx;
y2[i] = d - cy;
int tmp = cx;
cx = -cy;
cy = tmp;
}
long long anum, den, bnum;
bool ans = false;
for (int i = 0; i < 4; i++) {
den = x * x + y * y;
if (den == 0) {
if (x2[i] == 0 and y2[i] == 0) {
ans = true;
break;
}
continue;
}
anum = x * x2[i] + y * y2[i];
bnum = x * y2[i] - y * x2[i];
if ((anum % den == 0) && (bnum % den == 0)) {
ans = true;
break;
}
}
if (ans) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
s << "{";
for (int i = 0; i < t.size(); i++)
s << t[i] << (i == t.size() - 1 ? "" : ",");
return s << "}" << endl;
}
bool div(complex<long long> q, complex<long long> p) {
q *= complex<long long>(p.real(), -p.imag());
long long pm = p.real() * p.real() + p.imag() * p.imag();
return (q.real() % pm == 0 && q.imag() % pm == 0);
}
int main() {
ios_base::sync_with_stdio(0);
long long a1, a2, b1, b2, c1, c2;
cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
complex<long long> C(c1, c2), A(a1, a2), B(b1, b2);
complex<long long> i(0, 1);
if (C == complex<long long>(0, 0)) {
for (int j = 0; j < 9; j++) {
A *= i;
if (A == B) {
cout << "YES";
return 0;
}
}
cout << "NO";
return 0;
}
for (int j = 0; j < 9; j++) {
A *= i;
if (div(B - A, C)) {
cout << "YES";
return 0;
}
}
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, u, v, x, y, o;
bool check(long long a, long long b) {
if (!o) return (a == u && b == v);
return ((u - a) * x + (v - b) * y) % o == 0 &&
((a - u) * y + (v - b) * x) % o == 0;
}
int main() {
cin >> a >> b >> u >> v >> x >> y;
o = x * x + y * y;
if (check(a, b) || check(b, -a) || check(-a, -b) || check(-b, a))
cout << "YES";
else
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
pair<long long int, long long int> mult(pair<long long int, long long int> x,
pair<long long int, long long int> y) {
return pair<long long int, long long int>(
x.first * y.first - x.second * y.second,
x.first * y.second + x.second * y.first);
}
pair<long long int, long long int> sub(pair<long long int, long long int> x,
pair<long long int, long long int> y) {
return pair<long long int, long long int>(x.first - y.first,
x.second - y.second);
}
pair<long long int, long long int> conj(pair<long long int, long long int> x) {
return pair<long long int, long long int>(x.first, -x.second);
}
long long int lenSqr(pair<long long int, long long int> x) {
return x.first * x.first + x.second * x.second;
}
int main() {
ios_base::sync_with_stdio(0);
pair<long long int, long long int> A, B, C;
cin >> A.first >> A.second >> B.first >> B.second >> C.first >> C.second;
pair<long long int, long long int> iK(1, 0);
bool good = false;
for (int i = (0); i <= (3); ++i) {
if (mult(A, iK) == B) good = true;
pair<long long int, long long int> R = sub(B, mult(A, iK));
R = mult(R, conj(C));
long long int d = lenSqr(C);
if (d && R.first % d == 0 && R.second % d == 0) good = true;
iK = mult(iK, pair<long long int, long long int>(0, 1));
}
if (good)
cout << "YES";
else
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int stmp;
struct vrt {
long long x, y;
vrt() {}
vrt(long long x, long long y) : x(x), y(y) {}
vrt operator-(const vrt& rhs) const { return vrt(x - rhs.x, y - rhs.y); }
long long operator*(const vrt& rhs) const { return x * rhs.x + y * rhs.y; }
long long len() const { return x * x + y * y; }
vrt rot() {
vrt r;
r.y = x;
r.x = -y;
return r;
}
};
vrt scan() {
vrt a;
cin >> a.x;
cin >> a.y;
return a;
}
bool solve(vrt t, vrt c) {
long long a = t * c;
long long b = t * c.rot();
long long cc = c.rot().len();
if (cc == 0) return t.x == 0 && t.y == 0;
if (0) cout << "a " << a << " b " << b << " cc " << (int)cc << endl;
long long aa = a;
long long bb = b;
return aa % cc == 0 && bb % cc == 0;
}
bool test(vrt a, vrt b, vrt c) {
for (int(i) = 0; (i) < int(4); (i)++) {
if (solve(b - a, c)) return 1;
a = a.rot();
}
return 0;
}
int main() {
vrt a, b, c;
a = scan();
b = scan();
c = scan();
if (test(a, b, c))
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long xa, ya, xb, yb, xc, yc, xd, yd;
bool getAC() {
if (xc == 0 && yc == 0) {
if (xd == 0 && yd == 0) {
return true;
} else
return false;
} else {
long long tmp = xc * xc + yc * yc;
long long t1 = yd * xc - xd * yc;
long long t2 = yd * yc + xd * xc;
if (t1 % tmp == 0 && t2 % tmp == 0) {
return true;
} else
return false;
}
}
int main() {
cin >> xa >> ya >> xb >> yb >> xc >> yc;
for (int i = 0; i < 4; i++) {
if (i == 0) {
xd = xb - xa;
yd = yb - ya;
} else if (i == 1) {
xd = xb - ya;
yd = yb + xa;
} else if (i == 2) {
xd = xb + xa;
yd = yb + ya;
} else if (i == 3) {
xd = xb + ya;
yd = yb - xa;
}
if (getAC()) {
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct vect {
long long x, y;
vect() {}
vect(long long a, long long b) {
x = a;
y = b;
}
};
vect operator+(const vect& a, const vect& b) {
return vect(a.x + b.x, a.y + b.y);
}
vect operator-(const vect& a, const vect& b) {
return vect(a.x - b.x, a.y - b.y);
}
vect mul(const vect& a) { return vect(-a.y, a.x); }
bool solve(vect c, vect d) {
if (c.x == 0) {
if (c.y != 0) {
if (d.x % c.y == 0 && d.y % c.y == 0) return true;
return false;
} else
return d.x == 0 && d.y == 0;
}
long long p = d.y * c.x - c.y * d.x;
long long q = c.x * c.x + c.y * c.y;
if (p % q) return false;
long long b = p / q;
if ((d.x + b * c.y) % c.x) return false;
return true;
}
int main() {
vect a, b, c;
cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
if (solve(c, b - a) || solve(c, b - mul(a)) || solve(c, b + a) ||
solve(c, b + mul(a)))
printf("YES");
else
printf("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
long long ax, ay, bx, by, cx, cy;
int solve(long long x, long long y) {
x = bx - x, y = by - y;
if (cx == 0 && cy == 0) {
if (x == 0 && y == 0) return 1;
return 0;
} else {
if ((y * cx - x * cy) % (cy * cy + cx * cx) != 0) return 0;
long long b = (y * cx - x * cy) / (cy * cy + cx * cx);
if (cx) {
if ((x + b * cy) % cx != 0) return 0;
return 1;
} else if (cy) {
if (y % cy != 0) return 0;
return 1;
} else {
if (y == 0) return 1;
return 0;
}
}
}
int main() {
while (
~scanf("%lld %lld %lld %lld %lld %lld", &ax, &ay, &bx, &by, &cx, &cy)) {
int flag = 0;
if (solve(ax, ay)) flag = 1;
if (solve(-ax, -ay)) flag = 1;
if (solve(ay, -ax)) flag = 1;
if (solve(-ay, ax)) flag = 1;
if (flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool solve(long long a, long long b, long long c, long long d, long long e,
long long f) {
if ((e || f) && (!a && !b && !c && !d)) return false;
long long det = a * d - b * c;
if (det == 0) {
return abs(f * a) == abs(c * e);
} else {
return abs(d * e - b * f) % det == 0 && abs(-c * e + a * f) % det == 0;
}
}
int ax, ay, bx, by, cx, cy;
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
bool flag = false;
for (int i = 0; i < 4; i++) {
if (solve(cx, -cy, cy, cx, bx - ax, by - ay)) flag = true;
swap(ax, ay);
ax = -ax;
}
printf("%s\n", flag ? "YES" : "NO");
}
|
#include <bits/stdc++.h>
using namespace std;
double const pi = 3.1415926535897932384626433832795;
int const inf = (int)1e9;
long long const inf64 = (long long)2e18;
const string name = "c";
long long ax, ay, bx, by, cx, cy;
void rotate(long long &x, long long &y) {
long long xx = -y, yy = x;
x = xx, y = yy;
}
void answer() {
cout << "YES" << endl;
exit(0);
}
void solve(long long x, long long y) {
if (cx == 0 && cy == 0) {
if (x == 0 && y == 0) answer();
return;
}
if (cx == 0 || cy == 0) {
long long zn = cx + cy;
if (zn < 0) zn = -zn;
if (x % zn == 0 && y % zn == 0) answer();
return;
}
if ((x * cy - y * cx) % (cx * cx + cy * cy) == 0 &&
(y * cy + x * cx) % (cx * cx + cy * cy) == 0)
answer();
}
int main() {
cin >> ax >> ay;
cin >> bx >> by;
cin >> cx >> cy;
for (int i = 0; i < (int)4; i++) {
for (int j = 0; j < (int)4; j++) {
solve(bx - ax, by - ay);
rotate(bx, by);
}
rotate(ax, ay);
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct pnt {
int x, y;
long long dist() { return 1ll * x * x + 1ll * y * y; }
pnt operator-(const pnt &a) const { return pnt{x - a.x, y - a.y}; }
long long operator*(const pnt &a) const {
return 1ll * x * a.y - 1ll * y * a.x;
}
void in() { scanf("%d%d", &x, &y); }
void rot() {
swap(x, y);
x *= -1;
}
bool net(pnt a) {
if (x == 0 && y == 0) return a.x == 0 && a.y == 0;
return a.dist() % dist() == 0 && a * (*this) % dist() == 0;
}
} A, B, C;
int main() {
A.in(), B.in(), C.in();
if (C.net(B - A)) {
puts("YES");
return 0;
}
A.rot();
if (C.net(B - A)) {
puts("YES");
return 0;
}
A.rot();
if (C.net(B - A)) {
puts("YES");
return 0;
}
A.rot();
if (C.net(B - A)) {
puts("YES");
return 0;
}
puts("NO");
}
|
#include <bits/stdc++.h>
using namespace std;
int T;
long long xa, xb, xc, ya, yb, yc;
long long dx, dy;
bool gao(long long xc, long long yc) {
if (xc == 0 && yc == 0) return false;
return (dx * xc + dy * yc) % (xc * xc + yc * yc) == 0;
}
bool check(long long xa, long long ya) {
dx = xb - xa;
dy = yb - ya;
if (dx == 0 && dy == 0) return true;
return gao(xc, yc) && gao(-yc, xc);
}
bool judge() {
if (check(xa, ya)) return true;
if (check(-ya, xa)) return true;
if (check(-xa, -ya)) return true;
if (check(ya, -xa)) return true;
return false;
}
int main() {
scanf("%lld%lld%lld%lld%lld%lld", &xa, &ya, &xb, &yb, &xc, &yc);
printf("%s\n", judge() ? "YES" : "NO");
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
const double PI = 2 * acos(0.0);
const double EPS = 1e-8;
const int INF = (1 << 30) - 1;
long long x0, yyyyy0, x1, yyyyy1, x, y;
bool can(long long x0, long long yyyyy0, long long x, long long y) {
long long n = ((x0 * x + yyyyy0 * y) >= 0 ? (x0 * x + yyyyy0 * y)
: -(x0 * x + yyyyy0 * y));
;
long long d = x * x + y * y;
if (d == 0) {
return (x0 == 0 && yyyyy0 == 0);
};
if (n % d > 0) return false;
n = ((x0 * y - yyyyy0 * x) >= 0 ? (x0 * y - yyyyy0 * x)
: -(x0 * y - yyyyy0 * x));
;
if (n % d > 0) return false;
return true;
};
int main() {
cin >> x0 >> yyyyy0 >> x1 >> yyyyy1 >> x >> y;
for (int i = 0; i < 4; ++i) {
if (can(x1 - x0, yyyyy1 - yyyyy0, x, y)) {
cout << "YES";
return 0;
};
long long tx, ty;
tx = yyyyy1;
ty = -x1;
x1 = tx;
yyyyy1 = ty;
};
cout << "NO";
return 0;
};
|
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int N = 1001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long x, y, dx, dy, xx, yy;
bool ok(long long tx, long long ty) {
long long d = gcd(abs(dx), abs(dy));
if (d == 0) {
return tx == 0 && ty == 0;
}
if (tx % d || ty % d) return false;
long long temp = dx * dx + dy * dy;
if (temp == 0) {
return tx == ty;
} else {
long long sum1 = tx * dx + dy * ty;
long long sum2 = dy * tx - dx * ty;
return sum1 % temp == 0 && sum2 % temp == 0;
}
}
bool judge() {
if (ok(x - xx, y - yy) || ok(x + xx, y + yy) || ok(x + yy, y - xx) ||
ok(x - yy, y + xx))
return true;
return false;
}
int main() {
while (cin >> x >> y >> xx >> yy >> dx >> dy) {
puts(judge() ? "YES" : "NO");
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
long long AX[4], AY[4], CX[4], CY[4];
bool judge(long long ax, long long ay, long long cx, long long cy) {
if (cx == 0 && cy == 0) return ax == bx && ay == by;
long long zi1 = abs((bx - ax) * cx + (by - ay) * cy);
long long zi2 = abs(cx * (by - ay) - cy * (bx - ax));
long long mu = abs(cx * cx + cy * cy);
if (mu)
if (zi1 % mu || zi2 % mu) return 0;
if (!mu && (zi1 || zi2)) return 0;
return 1;
}
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
AX[0] = ax, AY[0] = ay;
AX[1] = -ay, AY[1] = ax;
AX[2] = -ax, AY[2] = -ay;
AX[3] = ay, AY[3] = -ax;
CX[0] = cx, CY[0] = cy;
CX[1] = -cy, CY[1] = cx;
CX[2] = -cx, CY[2] = -cy;
CX[3] = cy, CY[3] = -cx;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (judge(AX[i], AY[i], CX[j], CY[j])) return cout << "YES", 0;
cout << "NO";
}
|
#include <bits/stdc++.h>
using ll = long long;
bool achievable(ll X, ll Y, ll xc, ll yc) {
if (!(xc | yc)) return !(X | Y);
ll vol = xc * xc + yc * yc;
if ((X * xc + Y * yc) % vol) return 0;
if ((X * yc - Y * xc) % vol) return 0;
return 1;
}
int main() {
ll xa, ya, xb, yb, xc, yc;
scanf("%lld%lld%lld%lld%lld%lld", &xa, &ya, &xb, &yb, &xc, &yc);
printf("%s\n", achievable(xb - xa, yb - ya, xc, yc) ||
achievable(xb - ya, yb + xa, xc, yc) ||
achievable(xb + xa, yb + ya, xc, yc) ||
achievable(xb + ya, yb - xa, xc, yc)
? "YES"
: "NO");
}
|
#include <bits/stdc++.h>
long long Ax, Ay, Bx, By, dx, dy, d;
bool check(long long x, long long y) {
return !d && !x && !y ||
d && (dx * y - dy * x) % d == 0 && (dx * x + dy * y) % d == 0;
}
int main() {
scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &Ax, &Ay, &Bx, &By, &dx, &dy);
long long bx[] = {Bx, -By, -Bx, By}, by[] = {By, Bx, -By, -Bx};
d = dx * dx + dy * dy;
for (int j = 0; j < 4; ++j)
if (check(bx[j] - Ax, by[j] - Ay)) return puts("YES"), 0;
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int MaxN = 10004, NA = -1, MaxC = 0x3F3F3F3F;
bool go(long long x1, long long y1, long long x2, long long y2, long long x3,
long long y3) {
long long a[2][2];
long long v[2];
long long w[2];
long long d;
a[0][0] = x2;
a[0][1] = y2;
a[1][0] = -y2;
a[1][1] = x2;
v[0] = x3 - x1;
v[1] = y3 - y1;
d = (long long)x2 * x2 + (long long)y2 * y2;
if (d == 0) return v[0] == 0 && v[1] == 0;
w[0] = a[0][0] * v[0] + a[0][1] * v[1];
w[1] = a[1][0] * v[0] + a[1][1] * v[1];
assert(true);
assert(true);
assert(true);
assert(true);
assert(true);
assert(true);
assert(true);
if (w[0] % d == 0 && w[1] % d == 0) return true;
return false;
}
int main(void) {
int x1, y1, x2, y2, x3, y3;
while (scanf(" %d %d %d %d %d %d", &x1, &y1, &x3, &y3, &x2, &y2) != EOF) {
if (go(x1, y1, x2, y2, +x3, +y3) || go(x1, y1, x2, y2, -y3, +x3) ||
go(x1, y1, x2, y2, -x3, -y3) || go(x1, y1, x2, y2, +y3, -x3))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct vect {
long long x, y;
void read() { cin >> x >> y; }
long long length() { return x * x + y * y; }
};
long long operator*(vect a, vect b) { return a.x * b.x + a.y * b.y; }
vect rot(vect a) {
vect b;
b.x = a.y;
b.y = -a.x;
return b;
}
vect opposite(vect a) {
vect b;
b.x = -a.x;
b.y = -a.y;
return b;
}
int main() {
vect a, b, c, d;
a.read();
b.read();
c.read();
if (c.x == 0 && c.y == 0) {
if (a.length() == b.length() && (a * b == 0 || rot(a) * b == 0)) {
cout << "YES";
return 0;
} else {
cout << "NO";
return 0;
}
}
d = rot(c);
for (int i = 0; i < 4; i++) {
long long x = b.x - a.x, y = b.y - a.y;
if (!c.x) swap(c, d);
long long rest1 = (y * c.x - x * c.y) % (c.x * d.y - c.y * d.x);
long long beta = (y * c.x - x * c.y) / (c.x * d.y - c.y * d.x);
long long rest2 = (x - beta * d.x) % c.x;
long long alpha = (x - beta * d.x) / c.x;
if (rest1 == 0 && rest2 == 0) {
cout << "YES";
return 0;
}
if (i % 2 == 0)
a = opposite(a);
else
a = rot(a);
}
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void rot(pair<int, int> &p) {
swap(p.first, p.second);
p.first *= -1;
}
double norm(pair<int, int> p) {
double x = p.first, y = p.second;
return sqrt(x * x + y * y);
}
long long qua(double siz, pair<int, int> b) {
double bs = norm(b);
return round(siz / bs);
}
bool make(pair<int, int> t, pair<int, int> b) {
if (t.first == 0 && t.second == 0) return true;
if (b.first == 0 && b.second == 0) return t == b;
double bm = norm(b);
double dp = (t.first * 1.0 * b.first + t.second * 1.0 * b.second);
double sz = dp / bm;
long long v1 = qua(sz, b);
double rs = sqrt(max(pow(norm(t), 2) - sz * sz, 1e-9));
long long v2 = qua(rs, b);
long long x = b.first * v1;
long long y = b.second * v1;
for (int i = 0; i < 4; i++) {
if (x + b.first * v2 == t.first && y + b.second * v2 == t.second) {
return true;
}
rot(b);
}
return false;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0), cout.precision(15);
pair<int, int> a, b, c;
cin >> a.first >> a.second;
cin >> b.first >> b.second;
cin >> c.first >> c.second;
for (int i = 0; i < 4; i++) {
pair<int, int> d = {b.first - a.first, b.second - a.second};
if (make(d, c)) {
cout << "YES\n";
return 0;
}
rot(a);
}
cout << "NO\n";
}
|
#include <bits/stdc++.h>
const double eps = 1e-9;
const double pi = acos(-1);
using namespace std;
bool divis(const complex<long long>& a, const complex<long long>& b) {
complex<long long> C(0, 0);
C = a / b;
return (b * C == a);
}
int main() {
long long x, y;
cin >> x >> y;
complex<long long> A(x, y);
cin >> x >> y;
complex<long long> B(x, y);
cin >> x >> y;
complex<long long> C(x, y);
complex<long long> I(0, 1);
int ans = 0;
if (C.real() == 0 && C.imag() == 0) {
if (A == B)
ans = 1;
else if (-A == B)
ans = 1;
else if (B == A * I)
ans = 1;
else if (B == -A * I)
ans = 1;
} else {
if (divis(B - A, C))
ans = 1;
else if (divis(B + A, C))
ans = 1;
else if (divis(B - A * I, C))
ans = 1;
else if (divis(B + A * I, C))
ans = 1;
}
if (ans)
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = 3.14159265358979323846264338327950288419716939937511;
const double eps = 1e-11;
char ch_ch_ch[1 << 20];
string gs() {
scanf("%s", ch_ch_ch);
return string(ch_ch_ch);
}
string gl() {
gets(ch_ch_ch);
return string(ch_ch_ch);
}
vector<double> prob;
vector<vector<double> > a;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
vector<double> gauss2(vector<vector<double> > a, int &sol) {
int n = a.size(), m = a[0].size();
vector<double> res;
vector<char> was(m, 0);
sol = -1;
int i, p;
for (i = 0, p = 0; p < n && i < m; ++i) {
int k = p;
for (int j = (p + 1); j < (n); ++j)
if (abs(a[j][i]) > abs(a[k][i])) k = j;
if (abs(a[k][i]) < eps) continue;
for (int j = (i); j < (m); ++j) swap(a[k][j], a[p][j]);
for (int j = (i + 1); j < (m); ++j) a[p][j] /= a[p][i];
a[p][i] = 1;
was[i] = 1;
for (int j = 0; j < (n); ++j)
if (j != p) {
for (int k = (i + 1); k < (m); ++k) a[j][k] -= a[j][i] * a[p][k];
a[j][i] = 0;
}
if (i == m - 1) sol = 0;
++p;
}
if (sol == -1 && p < m - 1)
sol = 2;
else if (sol == -1)
sol = 1;
p = 0;
res.resize(m - 1, 0);
for (int i = 0; i < (m - 1); ++i)
if (was[i]) res[i] = a[p++][m - 1];
return res;
}
int rank(vector<vector<double> > a) {
int n = a.size(), m = a[0].size();
int p = 0;
for (int i = 0; i < m && p < min(n, m); ++i) {
int maxrow = p;
for (int j = p + 1; j < n; ++j)
if (abs(a[maxrow][i]) < abs(a[j][i])) maxrow = j;
swap(a[maxrow], a[p]);
if (abs(a[p][i]) < eps) continue;
for (int j = i + 1; j < m; ++j) a[p][j] /= a[p][i];
a[p][i] = 1;
for (int j = 0; j < n; ++j)
if (p != j) {
for (int k = i + 1; k < m; ++k) a[j][k] -= a[j][i] * a[p][k];
a[j][i] = 0;
}
p++;
}
return p;
}
int solve(int x, int y, int tx, int ty, int dx, int dy) {
a.resize(2, vector<double>(3, 0));
a[0][0] = dx, a[0][1] = dy, a[0][2] = tx - x;
a[1][0] = dy, a[1][1] = -dx, a[1][2] = ty - y;
int r;
prob = gauss2(a, r);
if (r == 0) {
return 0;
}
if (r == 1) {
long long kx = (long long)floor(prob[0] + 0.5);
long long ky = (long long)floor(prob[1] + 0.5);
if (dx * kx + dy * ky == (long long)(tx - x) &&
dy * kx - dx * ky == (long long)(ty - y))
return 1;
return 0;
}
if (gcd(abs(dx), abs(dy)) == 0) return abs(tx - x) == 0;
if (abs(tx - x) % gcd(abs(dx), abs(dy)) == 0) return 1;
return 0;
}
void solution() {
int x, y, dx, dy, tx, ty;
scanf("%d%d%d%d%d%d", &x, &y, &tx, &ty, &dx, &dy);
if (solve(x, y, tx, ty, dx, dy) || solve(x, y, -ty, tx, dx, dy) ||
solve(x, y, ty, -tx, dx, dy) || solve(x, y, -tx, -ty, dx, dy))
printf("YES\n");
else
printf("NO\n");
}
int main() {
solution();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000;
const int MAXN = 1e7 + 5;
struct Vector {
long long x, y;
};
Vector ta[4], a, b, c;
int f;
long long mu;
bool judge(Vector a) {
Vector tmp;
tmp.x = b.x - a.x, tmp.y = b.y - a.y;
if (mu == 0) {
if (tmp.x == 0 && tmp.y == 0) {
return true;
}
return false;
}
if ((((tmp.x * c.y - tmp.y * c.x) % mu) == 0) &&
(((tmp.x * c.x + tmp.y * c.y) % mu) == 0))
return true;
return false;
}
int main() {
scanf("%lld%lld%lld%lld%lld%lld", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);
ta[0] = a;
ta[1].x = -a.x, ta[1].y = -a.y;
ta[2].x = a.y, ta[2].y = -a.x;
ta[3].x = -a.y, ta[3].y = a.x;
mu = c.x * c.x + c.y * c.y;
for (int i = 0; i < 4; i++)
if (judge(ta[i])) {
f = 1;
break;
}
if (f)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
int check(long long xa, long long ya, long long xc, long long yc, long long xb,
long long yb) {
long long a1, b1, c1, a2, b2, c2, a3, b3, c3, a4, b4, c4, c0, d0, c, d;
long long x1, y1, x2, y2, x3, y3, x4, y4, f1, f2;
if (xc == 0 && yc == 0) {
if (xa == xb && ya == yb) return 1;
return 0;
}
x1 = xa;
y1 = ya;
x2 = x1 + xc;
y2 = y1 + yc;
x3 = xa - yc;
y3 = ya + xc;
x4 = x3 + xc;
y4 = y3 + yc;
a1 = y2 - y1;
b1 = x1 - x2;
c1 = x2 * y1 - x1 * y2;
a2 = y4 - y3;
b2 = x3 - x4;
c2 = x4 * y3 - x3 * y4;
a3 = y3 - y1;
b3 = x1 - x3;
c3 = x3 * y1 - x1 * y3;
a4 = y4 - y2;
b4 = x2 - x4;
c4 = x4 * y2 - x2 * y4;
c0 = c2 - c1;
d0 = c4 - c3;
c = -a1 * xb - b1 * yb;
d = b1 * xb - a1 * yb;
f1 = f2 = 0;
if (c == c0 && c0 == 0) f1 = 1;
if (c0 == 0 && c != 0) f1 = -1;
if (!f1)
if (!((c - c1) % c0))
f1 = 1;
else
f1 = -1;
if (d == d0 && d0 == 0) f2 = 1;
if (d0 == 0 && d != 0) f2 = -1;
if (!f2)
if (!((d - c3) % d0))
f2 = 1;
else
f2 = -1;
if (f1 + f2 == 2) return 1;
return 0;
}
int main() {
long long xa, ya, xc, yc, xb, yb;
scanf("%lld %lld %lld %lld %lld %lld", &xa, &ya, &xb, &yb, &xc, &yc);
if (check(xa, ya, xc, yc, xb, yb)) {
printf("YES");
return 0;
}
if (check(-xa, -ya, xc, yc, xb, yb)) {
printf("YES");
return 0;
}
if (check(-ya, xa, xc, yc, xb, yb)) {
printf("YES");
return 0;
}
if (check(ya, -xa, xc, yc, xb, yb)) {
printf("YES");
return 0;
}
printf("NO");
}
|
#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
for (int(i) = 0; (i) < (t.size()); ++(i)) s << t[i] << " ";
return s;
}
bool check(long long cx, long long cy, long long ux, long long uy) {
if (cx == 0 && cy == 0) {
return (cx == ux && cy == uy);
}
long long detA = -cx * cx - cy * cy;
long long detA1 = -cx * ux - cy * uy;
long long detA2 = cx * uy - ux * cy;
if (detA1 % detA != 0) return false;
if (detA2 % detA != 0) return false;
return true;
}
int main() {
int(ax1), (ay1);
scanf("%d %d", &(ax1), &(ay1));
int(bx1), (by1);
scanf("%d %d", &(bx1), &(by1));
int(cx1), (cy1);
scanf("%d %d", &(cx1), &(cy1));
long long ax = ax1, bx = bx1, cx = cx1, ay = ay1, by = by1, cy = cy1;
vector<pair<long long, long long> > v;
v.push_back(make_pair(bx - ax, by - ay));
v.push_back(make_pair(bx - ay, by + ax));
v.push_back(make_pair(bx + ax, by + ay));
v.push_back(make_pair(bx + ay, by - ax));
for (int(j) = 0; (j) < (4); ++(j))
if (check(cx, cy, v[j].first, v[j].second)) {
printf("YES\n");
return 0;
}
printf("NO\n");
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
long long xabs(long long a) { return a < 0 ? -a : +a; }
bool check(long long p, long long q, long long x, long long y, long long a,
long long b) {
if (a * x + b * y == p && a * y - b * x == q)
return true;
else
return false;
}
bool can(long long ax, long long ay, long long bx, long long by, long long x,
long long y) {
long long p = bx - ax;
long long q = by - ay;
if (x == 0 && y == 0) {
if (p == 0 && q == 0)
return true;
else
return false;
}
if (y != 0) swap(x, y), swap(p, q);
long long b = (p * y - q * x) / (y * y + x * x);
long long a = (p - b * y) / x;
if (check(p, q, x, y, a, b))
return true;
else
return false;
}
int main() {
long long ax, ay, bx, by, x, y;
cin >> ax >> ay >> bx >> by >> x >> y;
bool fl = false;
for (int i = 0; i < 4; ++i) {
fl |= can(ax, ay, bx, by, x, y);
swap(ax, ay);
ax = -ax;
}
if (fl)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool div(const complex<long long>& a, const complex<long long>& b) {
complex<long long> c(0, 0);
c = a / b;
return (b * c == a);
}
int main() {
long long a, b;
cin >> a >> b;
complex<long long> A(a, b);
cin >> a >> b;
complex<long long> B(a, b);
cin >> a >> b;
complex<long long> C(a, b);
complex<long long> I(0, 1);
bool flag = 0;
if (C.real() == 0 && C.imag() == 0) {
if (A == B)
flag = 1;
else if (B == -A)
flag = 1;
else if (B == A * I)
flag = 1;
else if (B == -A * I)
flag = 1;
} else {
if (div(B - A, C))
flag = 1;
else if (div(B + A, C))
flag = 1;
else if (div(B - A * I, C))
flag = 1;
else if (div(B + A * I, C))
flag = 1;
}
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double i, k, l, j, x1, y1, x2, y2, x3, y3, a, b, c, d;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
if (x3 == 0 && y3 == 0) {
if ((x1 + x2) == 0 && (y2 + y1) == 0) {
cout << "YES" << endl;
return 0;
} else if ((x1 - x2) == 0 && (y2 - y1) == 0) {
cout << "YES" << endl;
return 0;
} else if ((x1 + y2) == 0 && (x2 - y1) == 0) {
cout << "YES" << endl;
return 0;
} else if ((x1 - y2) == 0 && (x2 + y1) == 0) {
cout << "YES" << endl;
return 0;
}
} else {
a = x1 + x2;
b = y1 + y2;
c = abs((a * x3 + b * y3) / (x3 * x3 + y3 * y3));
d = abs((b * x3 - a * y3) / (x3 * x3 + y3 * y3));
if (floor(c) == c && floor(d) == d) {
cout << "YES" << endl;
return 0;
}
a = -x1 + x2;
b = -y1 + y2;
c = abs((a * x3 + b * y3) / (x3 * x3 + y3 * y3));
d = abs((b * x3 - a * y3) / (x3 * x3 + y3 * y3));
if (floor(c) == c && floor(d) == d) {
cout << "YES" << endl;
return 0;
}
a = -y1 + x2;
b = x1 + y2;
c = abs((a * x3 + b * y3) / (x3 * x3 + y3 * y3));
d = abs((b * x3 - a * y3) / (x3 * x3 + y3 * y3));
if (floor(c) == c && floor(d) == d) {
cout << "YES" << endl;
return 0;
}
a = y1 + x2;
b = -x1 + y2;
c = abs((a * x3 + b * y3) / (x3 * x3 + y3 * y3));
d = abs((b * x3 - a * y3) / (x3 * x3 + y3 * y3));
if (floor(c) == c && floor(d) == d) {
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double epsilon = 1e-9;
int cxG, cyG;
set<pair<int, int> > reached;
void makeMove(int x, int y) {
queue<pair<int, int> > toMove;
toMove.push(make_pair(x, y));
pair<int, int> cur;
while (!toMove.empty()) {
cur = toMove.front();
toMove.pop();
x = cur.first;
y = cur.second;
if (reached.find(make_pair(y, -x)) == reached.end()) {
reached.insert(make_pair(y, -x));
toMove.push(make_pair(y, -x));
}
if (abs(x + cxG) < 200 && abs(y + cyG) < 200 &&
reached.find(make_pair(x + cxG, y + cyG)) == reached.end()) {
reached.insert(make_pair(x + cxG, y + cyG));
toMove.push(make_pair(x + cxG, y + cyG));
}
}
}
void tester() {
int ax, ay;
cin >> ax >> ay >> cxG >> cyG;
reached.insert(make_pair(ax, ay));
makeMove(ax, ay);
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
if (reached.find(make_pair(i, j)) == reached.end())
cout << " 0";
else
cout << " 1";
}
cout << endl;
}
}
bool tester(int ax, int ay, int bx, int by, int cx, int cy) {
cxG = cx;
cyG = cy;
reached.insert(make_pair(ax, ay));
makeMove(ax, ay);
return reached.find(make_pair(bx, by)) != reached.end();
}
bool tryIt(long long x, long long y, long long bx, long long by) {
if (bx == 0 && by == 0) {
return x == 0 && y == 0;
}
if ((x * bx + y * by) % (bx * bx + by * by) != 0) {
return false;
}
long long k = (x * bx + y * by) / (bx * bx + by * by);
if (by != 0) {
return (x - k * bx) % by == 0;
} else
return y % bx == 0;
}
bool solve(int ax, int ay, int bx, int by, int cx, int cy) {
int tmp;
while (cx < 0 || cy < 0) {
tmp = cx;
cx = cy;
cy = -tmp;
}
for (int j = 0; j < 4; j++) {
if (tryIt(bx - ax, by - ay, cx, cy)) {
return true;
}
tmp = ax;
ax = ay;
ay = -tmp;
}
return false;
}
int main() {
int ax, ay, bx, by, cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
bool does = solve(ax, ay, bx, by, cx, cy);
if (does)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int nextInt() {
int x;
scanf("%d", &x);
return x;
}
const int BUFSIZE = 100111;
char buf[BUFSIZE + 1];
string nextString() {
scanf("%s", buf);
return buf;
}
long long det(long long a, long long b, long long c, long long d) {
return a * d - b * c;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
bool isSolvable(long long A1, long long B1, long long C1, long long A2,
long long B2, long long C2) {
if (A1 == 0 && B1 == 0 && C1 != 0 || A2 == 0 && B2 == 0 && C2 != 0) {
return false;
}
long long D = det(A1, B1, A2, B2);
long long Dx = det(C1, B1, C2, B2);
long long Dy = det(A1, C1, A2, C2);
if (D == 0) {
if (A1 == 0 && B1 == 0) {
if (A2 == 0 && B2 == 0) {
return true;
} else {
return C2 % gcd(A2, B2) == 0;
}
} else {
return C1 % gcd(A1, B1) == 0;
}
}
return Dx % D == 0 && Dy % D == 0;
}
bool isSolvable(long long x, long long y, long long cx1, long long cx2,
long long cy1, long long cy2, long long x2, long long y2) {
return isSolvable(cx1, cy1, x2 - x, cx2, cy2, y2 - y);
}
int main() {
long long x1 = nextInt();
long long y1 = nextInt();
long long x2 = nextInt();
long long y2 = nextInt();
long long cx = nextInt();
long long cy = nextInt();
bool res = isSolvable(x1, y1, cx, cy, cy, -cx, x2, y2) ||
isSolvable(y1, -x1, -cx, -cy, cy, -cx, x2, y2) ||
isSolvable(-x1, -y1, -cx, -cy, -cy, cx, x2, y2) ||
isSolvable(-y1, x1, cx, cy, -cy, cx, x2, y2);
cout << (res ? "YES" : "NO") << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a1, b1, a2, b2, a3, b3;
bool is(long long x, long long y) {
x = a2 - x;
y = b2 - y;
if (a3 == 0 && b3 == 0) {
if (x == 0 && y == 0) return true;
return false;
} else if (a3 == 0) {
if (x / b3 == (float)x / b3 && y / b3 == (float)y / b3) return true;
return false;
} else if (b3 == 0) {
if (x / a3 == (float)x / a3 && y / a3 == (float)y / a3) return true;
return false;
} else {
long long b = (x * b3 - y * a3) / (a3 * a3 + b3 * b3);
if ((a3 * a3 + b3 * b3) * b != x * b3 - y * a3)
return false;
else {
long long a = (x - b * b3) / a3;
if (a * a3 + b * b3 == x) return true;
return false;
}
}
}
int main() {
scanf("%lld%lld", &a1, &b1);
scanf("%lld%lld", &a2, &b2);
scanf("%lld%lld", &a3, &b3);
if (is(a1, b1) || is(b1, -a1) || is(-a1, -b1) || is(-b1, a1)) {
printf("YES\n");
return 0;
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct point {
long long x, y;
} a, b, c;
point operator-(point a, point b) { return {a.x - b.x, a.y - b.y}; }
point operator+(point a, point b) { return {a.x + b.x, a.y + b.y}; }
point operator*(long long m, point a) { return {a.x * m, a.y * m}; }
bool operator==(point a, point b) {
if (a.x == b.x && a.y == b.y) return 1;
return 0;
}
point rot(point ret) { return {ret.y, -ret.x}; }
bool check(point d) {
d = b - d;
if (c.x == 0 && c.y == 0) {
if (d.x == 0 && d.y == 0) return true;
return false;
}
if (c.x == 0) {
long long bb = d.x / c.y;
long long aa = d.y / c.y;
if (aa * c + bb * rot(c) == d)
return true;
else
return false;
} else if (c.y == 0) {
long long aa = d.x / c.x;
long long bb = -d.y / c.x;
if (aa * c + bb * rot(c) == d)
return true;
else
return false;
} else {
double bb2 = ((double)d.y - ((double)d.x * c.y) / (double)c.x) /
((double)-c.x - ((double)c.y * c.y) / (double)c.x);
double aa2 = ((double)d.x - (double)bb2 * c.y) / (double)c.x;
bb2 = round(bb2);
aa2 = round(aa2);
long long aa = aa2;
long long bb = bb2;
if (aa * c + bb * rot(c) == d)
return true;
else
return false;
}
}
int main() {
scanf("%lld %lld", &a.x, &a.y);
scanf("%lld %lld", &b.x, &b.y);
scanf("%lld %lld", &c.x, &c.y);
for (int i = 0; i <= 3; i++) {
if (check(a)) {
printf("YES\n");
return 0;
}
a = rot(a);
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
bool f(long long P, long long Q) {
if (cx == 0 && cy == 0) return P == 0 && Q == 0;
long long r1 = (P * cx + Q * cy) % ((cx) * (cx) + (cy) * (cy));
long long r2 = (P * cy - Q * cx) % ((cx) * (cx) + (cy) * (cy));
return r1 == 0 && r2 == 0;
}
int main() {
cout << setprecision(9);
cin >> ax >> ay >> bx >> by >> cx >> cy;
if (f(bx - ax, by - ay) || f(bx - ay, by + ax) || f(bx + ax, by + ay) ||
f(bx + ay, by - ax))
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long x1, y8477234, x2, y2, x3, y3, ix3, iy3;
int i;
long long sqr(long long x) { return (x * x); }
bool check(long long xx, long long yy) {
long long aa = xx * x3 + yy * y3;
long long bb = xx * ix3 + yy * iy3;
long long cc = sqr(x3) + sqr(y3);
if (cc == 0) return ((xx == 0) && (yy == 0));
return ((aa % cc == 0) && (bb % cc == 0));
}
int main() {
cin >> x1 >> y8477234 >> x2 >> y2 >> x3 >> y3;
ix3 = -y3;
iy3 = x3;
for (i = 0; i < 4; i++) {
swap(x1, y8477234);
x1 = -x1;
if (check(x2 - x1, y2 - y8477234)) break;
}
if (i < 4)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.