text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
struct node {
long long x, y;
} a[4];
int judge(long long ax, long long ay, long long bx, long long by, long long cx,
long long cy) {
long long n;
if (cx == 0 && cy == 0) {
if (bx == ax && by == ay)
return 1;
else
return 0;
} else if (cx == 0) {
if ((bx - ax) % cy != 0)
return 0;
else {
n = (bx - ax) / cy;
if ((by - ay) % cy != 0)
return 0;
else
return 1;
}
} else if (cy == 0) {
if ((ay - by) % cx != 0)
return 0;
else {
if ((bx - ax) % cx != 0)
return 0;
else
return 1;
}
} else {
if (((bx - ax) * cy - (by - ay) * cx) % (cy * cy + cx * cx) != 0)
return 0;
else {
n = ((bx - ax) * cy - (by - ay) * cx) / (cy * cy + cx * cx);
if ((by - ay + n * cx) % cy != 0)
return 0;
else
return 1;
}
}
}
int main() {
long long ax, ay, bx, by, cx, cy, f;
while (
~scanf("%I64d%I64d%I64d%I64d%I64d%I64d", &ax, &ay, &bx, &by, &cx, &cy)) {
f = 0;
int i;
a[0].x = ax;
a[0].y = ay;
a[1].x = ay;
a[1].y = -ax;
a[2].x = -ax;
a[2].y = -ay;
a[3].x = -ay;
a[3].y = ax;
for (i = 0; i < 4; i++) {
if (judge(a[i].x, a[i].y, bx, by, cx, cy)) {
f = 1;
puts("YES");
break;
}
}
if (!f) puts("NO");
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
int main() {
cin >> ax >> ay >> bx >> by >> cx >> cy;
long long dx = bx - ax, dy = by - ay, D = cx * cx + cy * cy;
if (!D) {
complex<double> a = complex<double>(ax, ay), b = complex<double>(bx, by),
I = complex<double>(0.0, 1.0);
cout << (b == a || b == a * I || b == a * I * I || b == a * I * I * I
? "YES"
: "NO");
return 0;
}
if ((cx * dx + cy * dy) % D == 0 && (-cy * dx + cx * dy) % D == 0) {
cout << "YES";
return 0;
}
dx = bx + ay, dy = by - ax;
if ((cx * dx + cy * dy) % D == 0 && (-cy * dx + cx * dy) % D == 0) {
cout << "YES";
return 0;
}
dx = bx + ax, dy = by + ay;
if ((cx * dx + cy * dy) % D == 0 && (-cy * dx + cx * dy) % D == 0) {
cout << "YES";
return 0;
}
dx = bx - ay, dy = by + ax;
if ((cx * dx + cy * dy) % D == 0 && (-cy * dx + cx * dy) % D == 0) {
cout << "YES";
return 0;
}
cout << "NO";
}
|
#include <bits/stdc++.h>
using namespace std;
bool isSolvable(long long A, long long B, long long a, long long b) {
long long delr = a * a + b * b;
if (delr == 0) {
return A == 0 && B == 0;
}
if (((A * b - B * a) % delr == 0) && ((b * B + a * A) % delr == 0))
return true;
else
return false;
}
int main() {
long long x, y, a, b, A, B;
cin >> x >> y;
cin >> A >> B;
cin >> a >> b;
bool a1 = isSolvable(A - x, B - y, a, b);
bool a2 = isSolvable(A + y, B - x, a, b);
bool a3 = isSolvable(A + x, B + y, a, b);
bool a4 = isSolvable(A - y, B + x, a, b);
if (a1 || a2 || a3 || a4)
puts("YES");
else
puts("NO");
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);
}
int stk[70], tp;
template <class T>
inline void print(T p) {
if (!p) {
puts("0");
return;
}
while (p) stk[++tp] = p % 10, p /= 10;
while (tp) putchar(stk[tp--] + '0');
putchar('\n');
}
const long long mod = 1e9 + 7;
const double PI = acos(-1.0);
const long long inf = 1e18;
const int N = (1 << 20) + 10;
const int maxn = 1e6 + 10;
const double eps = 1e-12;
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>
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long maxn = 1e5 + 1;
const long long inf = 5e18;
const long long minf = -inf;
bool calc(long long a, long long b, long long e, long long c, long long d,
long long f) {
long long determinant = a * d - b * c;
if (determinant != 0) {
bool x = (e * d - b * f) % determinant;
bool y = (a * f - e * c) % determinant;
return !x && !y;
} else {
if (a == 0 && b == 0 && e == 0 && f == 0) return true;
}
return false;
}
bool solve() {
vector<pair<long long, long long>> v(4);
for (long long i = 1; i < 4; ++i) cin >> v[i].first >> v[i].second;
if (calc(v[3].first, -v[3].second, v[2].first - v[1].first, v[3].second,
v[3].first, v[2].second - v[1].second)) {
;
return true;
} else if (calc(v[3].first, -v[3].second, v[2].first + v[1].first,
v[3].second, v[3].first, v[2].second + v[1].second)) {
;
return true;
} else if (calc(v[3].first, -v[3].second, v[2].first + v[1].second,
v[3].second, v[3].first, v[2].second - v[1].first)) {
;
return true;
} else if (calc(v[3].first, -v[3].second, v[2].first - v[1].second,
v[3].second, v[3].first, v[2].second + v[1].first)) {
;
return true;
} else
return false;
}
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t = 1;
while (t--) {
if (solve()) {
cout << "YES"
<< "\n";
} else {
cout << "NO"
<< "\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
long long a, b, c, d, x, y;
cin >> a >> b >> x >> y >> c >> d;
string ret = "NO";
for (int i = 0; i < 4; ++i) {
long long xx = x - a;
long long yy = y - b;
if (xx == 0 && yy == 0)
ret = "YES";
else if (c || d) {
long long cc = -d;
long long dd = c;
long long dlt = c * dd - d * cc;
long long dlt1 = xx * dd - yy * cc;
long long dlt2 = c * yy - d * xx;
if ((dlt1 % dlt) == 0 && (dlt2 % dlt) == 0) ret = "YES";
}
swap(a, b);
a = -a;
}
cout << ret << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
const double eps = 1e-9;
struct vec {
long long x, y;
vec rotate() { return (vec){y, -x}; }
vec operator-(vec v) { return (vec){x - v.x, y - v.y}; }
long long operator*(vec v) { return x * v.y - y * v.x; }
} a, b, c;
bool check(vec u, vec v) {
if (!v.x && !v.y) return !u.x && !u.y;
long long m = v.x * v.x + v.y * v.y;
return u * v % m == 0 && u * v.rotate() % m == 0;
}
int main() {
cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
int flag = 1;
for (int i = 0; i < 4; i++) {
if (check(a - b, c)) {
puts("YES");
flag = 0;
break;
}
b = b.rotate();
}
if (flag) puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool verify(pair<long long, long long> b, pair<long long, long long> c) {
long long num1 = b.first * c.second - b.second * c.first,
den1 = c.first * c.first + c.second * c.second;
if (den1 == 0) return b == c;
if (num1 % den1 != 0) return 0;
long long k2 = num1 / den1;
long long num2 = b.first - k2 * c.second, den2 = c.first;
long long num2a = b.second + k2 * c.first, den2a = c.second;
if (den2 == 0) {
if (den2a == 0) {
return (num2 == 0 and num2a == 0);
} else {
return num2a % den2a == 0;
}
}
if (num2 % den2 != 0) return 0;
long long k1 = num2 / den2;
return 1;
}
int main() {
pair<long long, long long> a, b, c;
cin >> a.first >> a.second >> b.first >> b.second >> c.first >> c.second;
bool ret = verify(make_pair(b.first - a.first, b.second - a.second), c);
ret |= verify(make_pair(b.first - a.second, b.second + a.first), c);
ret |= verify(make_pair(b.first + a.first, b.second + a.second), c);
ret |= verify(make_pair(b.first + a.second, b.second - a.first), c);
if (ret)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
|
#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; }
int gauss(vector<vector<double> > a, vector<double> &res) {
vector<vector<double> > tmp = 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++;
if (i == m - 1) return 0;
}
a = tmp;
res.resize(n, 0);
for (int i = 0; i < n; ++i) {
int maxrow = i;
for (int j = i + 1; j < n; ++j)
if (abs(a[maxrow][i]) < abs(a[j][i])) maxrow = j;
swap(a[i], a[maxrow]);
for (int j = i + 1; j < m; ++j) a[i][j] /= a[i][i];
a[i][i] = 1;
for (int j = 0; j < n; ++j)
if (j != i) {
for (int k = i + 1; k < m; ++k) a[j][k] -= a[j][i] * a[i][k];
a[j][i] = 0;
}
}
for (int i = 0; i < n; ++i) res[i] = a[i][m - 1];
return (p < n ? 2 : 1);
}
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 = gauss(a, prob);
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;
struct pt {
long long x, y;
pt(long long xx, long long yy) { x = xx, y = yy; }
pt() {}
pt operator+(pt b) { return pt(x + b.x, y + b.y); }
pt gir() { return pt(-y, x); }
bool operator==(pt b) { return x == b.x and y == b.y; }
};
bool go(long long x1, long long y1, long long z1, long long x2, long long y2,
long long z2) {
long long det = x1 * y2 - x2 * y1;
long long a = z1 * y2 - y1 * z2;
long long b = x1 * z2 - x2 * z1;
if (det != 0)
return a % det == 0 and b % det == 0;
else
return z1 == z2 and z1 == 0;
}
int main() {
pt a, b, c;
cin >> a.x >> a.y;
cin >> b.x >> b.y;
cin >> c.x >> c.y;
pt d = c.gir();
bool vale = a == b;
if (go(c.x, d.x, b.x - a.x, c.y, d.y, b.y - a.y)) vale = true;
a = a.gir();
if (go(c.x, d.x, b.x - a.x, c.y, d.y, b.y - a.y)) vale = true;
a = a.gir();
if (go(c.x, d.x, b.x - a.x, c.y, d.y, b.y - a.y)) vale = true;
a = a.gir();
if (go(c.x, d.x, b.x - a.x, c.y, d.y, b.y - a.y)) vale = true;
if (vale)
cout << "YES\n";
else
cout << "NO\n";
}
|
#include <bits/stdc++.h>
using namespace std;
struct pnt {
long long x, y;
pnt(long long _x = 0, long long _y = 0) : x(_x), y(_y) {}
};
pnt operator+(const pnt& A, const pnt& B) { return pnt(A.x + B.x, A.y - B.y); }
pnt operator-(const pnt& A, const pnt& B) { return pnt(A.x - B.x, A.y - B.y); }
pnt rot(const pnt& A) { return pnt(A.y, -A.x); }
bool solve(pnt z, pnt c) {
long long z1 = z.x, z2 = z.y;
long long c1 = c.x, c2 = c.y;
if (c1 == 0 && c2 == 0) return z1 == 0 && z2 == 0;
long long num = c1 * z1 + c2 * z2;
long long denum = c1 * c1 + c2 * c2;
if (num % denum != 0) return false;
long long u = num / denum;
num = z1 - u * c1;
denum = c2;
if (denum != 0)
return num % denum == 0;
else
return z1 % c1 == 0 && z2 % c1 == 0;
}
int main() {
pnt A, B, C;
cin >> A.x >> A.y;
cin >> B.x >> B.y;
cin >> C.x >> C.y;
pnt x = A;
pnt y = B;
pnt c = C;
pnt xrot = x;
bool result = false;
for (int i = 1; i <= 4; i++) {
pnt z = y - xrot;
if (solve(z, c)) result = true;
xrot = rot(xrot);
}
if (result)
cout << "YES";
else
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a1, a2, b1, b2, c1, c2;
struct Point {
long long x, y;
Point(long long x = 0, long long y = 0) : x(x), y(y) {}
};
int exgcd(int a, int b, int& x, int& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int d = exgcd(b, a % b, x, y);
int t = x;
x = y;
y = t - a / b * y;
return d;
}
int dcmp(int x) {
if (x == 0) return 0;
return x < 0 ? -1 : 1;
}
Point operator+(const Point& a, const Point& b) {
return Point(a.x + b.x, a.y + b.y);
}
Point ans[5];
int main() {
scanf("%lld %lld %lld %lld %lld %lld", &a1, &a2, &b1, &b2, &c1, &c2);
ans[1] = Point(b1 - a1, b2 - a2);
ans[2] = Point(b1 - a2, b2 + a1);
ans[3] = Point(b1 + a1, b2 + a2);
ans[4] = Point(b1 + a2, b2 - a1);
if (c1 == 0 && c2 == 0) {
for (int i = 1; i <= 4; i++)
if (ans[i].x == 0 && ans[i].y == 0) {
printf("YES\n");
return 0;
}
printf("NO\n");
return 0;
}
for (int i = 1; i <= 4; i++) {
long long t1, t2;
if ((c1 * ans[i].x + c2 * ans[i].y) % (c1 * c1 + c2 * c2) != 0) continue;
t1 = (c1 * ans[i].x + c2 * ans[i].y) / (c1 * c1 + c2 * c2);
if ((c2 * ans[i].x - c1 * ans[i].y) % (c1 * c1 + c2 * c2) != 0) continue;
t2 = (c2 * ans[i].x - c1 * ans[i].y) / (c1 * c1 + c2 * c2);
printf("YES\n");
return 0;
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxint = -1u >> 1;
struct node {
long long x, y;
};
node A, B, C;
int gao2(long long ax, long long ay, long long bx, long long by, long long cx,
long long cy) {
if (cx == 0 && cy == 0) {
if (ax != bx || ay != by)
return 0;
else
return 1;
}
if (cx == 0) {
if (ax == bx && (by - ay) % cy == 0 && (by - ay) / cy >= 0) return 1;
if ((ax + by) % cy == 0 && (ax + by) / cy >= 0 && (bx - ay) % cy == 0 &&
(bx - ay) / cy >= 0)
return 1;
return 0;
}
if (cy == 0) {
if (ay == by && (bx - ax) % cx == 0 && (bx - ax) / cx >= 0) return 1;
if ((bx - ay) % cx == 0 && (bx - ay) / cx >= 0 && (-by - ax) % cx == 0 &&
(-ax - by) / cx >= 0)
return 1;
return 0;
}
long long a = ax + by;
long long b = bx - ay;
if ((bx - ax) % cx == 0 && (by - ay) % cy == 0 && (bx - ax) * cx >= 0 &&
(by - ay) * cy >= 0 && (bx - ax) / cx == (by - ay) / cy)
return 1;
long long x = (b * cy - a * cx) / (cy * cy + cx * cx);
long long y = (a * cy + b * cx) / (cy * cy + cx * cx);
if (x < 0 || y < 0) return 0;
if (y * cy - x * cx != a || x * cy + y * cx != b) return 0;
return 1;
}
int gao(long long ax, long long ay, long long bx, long long by, long long cx,
long long cy) {
int ans = 0;
ans |= gao2(ax, ay, bx, by, cx, cy);
ans |= gao2(ax, ay, by, -bx, cx, cy);
ans |= gao2(ax, ay, -bx, -by, cx, cy);
ans |= gao2(ax, ay, -by, bx, cx, cy);
return ans;
}
int main() {
cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y;
int ans = 0;
ans |= gao(A.x, A.y, B.x, B.y, C.x, C.y);
ans |= gao(A.y, -A.x, B.x, B.y, C.x, C.y);
ans |= gao(-A.x, -A.y, B.x, B.y, C.x, C.y);
ans |= gao(-A.y, A.x, B.x, B.y, C.x, C.y);
cout << (ans == 1 ? "YES" : "NO") << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
long long slove(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() {
scanf("%lld%lld", &ax, &ay);
scanf("%lld%lld", &bx, &by);
scanf("%lld%lld", &cx, &cy);
int flag = 0;
if (slove(ax, ay)) flag = 1;
if (slove(-ax, -ay)) flag = 1;
if (slove(ay, -ax)) flag = 1;
if (slove(-ay, ax)) flag = 1;
if (flag == 1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100004;
long long xa, ya, xb, yb, xc, yc;
bool f(long long xa, long long ya, long long xb, long long yb) {
xb -= xa;
yb -= ya;
if (xc == 0 && yc == 0) {
return xb == 0 && yb == 0;
}
long long k1 = (xb * xc + yb * yc) / (xc * xc + yc * yc);
long long k2 = (xc * yb - xb * yc) / (xc * xc + yc * yc);
return k1 * xc - k2 * yc == xb && k1 * yc + k2 * xc == yb;
}
int main() {
cin >> xa >> ya >> xb >> yb >> xc >> yc;
puts(f(xa, ya, xb, yb) || f(-ya, xa, xb, yb) || f(-xa, -ya, xb, yb) ||
f(ya, -xa, xb, yb)
? "YES"
: "NO");
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, maxn = 1e5 + 5;
struct p {
long long x, y;
p rotate() { return (p){y, -x}; }
p operator-(p v) { return (p){x - v.x, y - v.y}; }
long long operator*(p v) { return x * v.y - y * v.x; }
} a[3];
bool check(p u, p v) {
if (!v.x && !v.y) return !u.x && !u.y;
long long m = v.x * v.x + v.y * v.y;
return u * v % m == 0 && u * v.rotate() % m == 0;
}
int main(void) {
ios_base::sync_with_stdio(0);
for (int i = 0; i < 3; i++) cin >> a[i].x >> a[i].y;
for (int i = 0; i < 4; i++) {
if (check(a[0] - a[1], a[2])) {
puts("YES");
return 0;
}
a[1] = a[1].rotate();
}
puts("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;
puts((check(a, b) || check(b, -a) || check(-a, -b) || check(-b, a)) ? "YES"
: "NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long xa, ya, xb, yb, xc, yc, a, A, b;
cin >> xa >> ya >> xb >> yb >> xc >> yc;
if ((xa == xb) && (ya == yb))
cout << "YES";
else if ((xb == ya) && (yb == -xa))
cout << "YES";
else if ((xb == -xa) && (yb == -ya))
cout << "YES";
else if ((xb == -ya) && (yb == xa))
cout << "YES";
else if (((xc * xc) + (yc * yc)) == 0)
cout << "NO";
else {
A = (xc * xc) + (yc * yc);
a = (((xb - xa) * xc) + ((yb - ya) * yc));
b = (((xb - xa) * (-yc)) + ((yb - ya) * xc));
if ((a % A == 0) && (b % A == 0)) {
cout << "YES";
return 0;
}
a = (((xb + ya) * xc) + ((yb - xa) * yc));
b = (((xb + ya) * (-yc)) + ((yb - xa) * xc));
if ((a % A == 0) && (b % A == 0)) {
cout << "YES";
return 0;
}
a = (((xb + xa) * xc) + ((yb + ya) * yc));
b = (((xb + xa) * (-yc)) + ((yb + ya) * xc));
if ((a % A == 0) && (b % A == 0)) {
cout << "YES";
return 0;
}
a = (((xb - ya) * xc) + ((yb + xa) * yc));
b = (((xb - ya) * (-yc)) + ((yb + xa) * xc));
if ((a % A == 0) && (b % A == 0)) {
cout << "YES";
return 0;
}
cout << "NO";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long x[3], y[3];
bool ok(long long a, long long b) {
if (b < 0) b = -b;
if (b == 0) {
return a == 0;
}
return a % b == 0;
}
bool check(long long xx, long long yy) {
long long ex = x[1] - xx;
long long ey = y[1] - yy;
long long dx = x[2];
long long dy = y[2];
if (dx == 0 && dy == 0 && (ex != 0 || ey != 0)) return false;
if (ok(ex * dx + ey * dy, dx * dx + dy * dy) &&
ok(ex * dy - ey * dx, dy * dy + dx * dx)) {
return true;
}
return false;
}
bool work() {
if (check(x[0], y[0]) || check(-y[0], x[0]) || check(-x[0], -y[0]) ||
check(y[0], -x[0]))
return true;
return false;
}
int main() {
for (int i = 0; i < 3; i++) {
scanf("%I64d%I64d", &x[i], &y[i]);
}
puts(work() ? "YES" : "NO");
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; }
int gauss2(vector<vector<double> > a, vector<double> &res) {
int n = a.size(), m = a[0].size();
vector<char> was(m, 0);
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) return 0;
++p;
}
int rank = p;
p = 0;
res.resize(m - 1, 0);
for (int i = 0; i < (m - 1); ++i)
if (was[i]) res[i] = a[p++][m - 1];
if (rank < m - 1) return 2;
return 1;
}
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 = gauss2(a, prob);
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;
long long ax, ay, bx, by, cx, cy;
int aa(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 (cy * g == x && cy * h == y) return 1;
return 0;
} else if (cy == 0) {
long long g = x / cx, h = y / cx;
if (cx * g == x && cx * h == 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() {
scanf("%lld%lld%lld%lld%lld%lld", &ax, &ay, &bx, &by, &cx, &cy);
int f = 0;
if (aa(ax, ay) == 1) f = 1;
if (aa(-ax, -ay) == 1) f = 1;
if (aa(-ay, ax) == 1) f = 1;
if (aa(ay, -ax) == 1) f = 1;
if (f == 1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T Get_Max(const T& a, const T& b) {
return a < b ? b : a;
}
template <class T>
inline T Get_Min(const T& a, const T& b) {
return a < b ? a : b;
}
bool divisible(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 = false;
if (C.real() == 0 && C.imag() == 0) {
if (A == B)
flag = true;
else if (B == -A)
flag = true;
else if (B == A * I)
flag = true;
else if (B == -A * I)
flag = true;
} else {
if (divisible(B - A, C))
flag = true;
else if (divisible(B + A, C))
flag = true;
else if (divisible(B - A * I, C))
flag = true;
else if (divisible(B + A * I, C))
flag = true;
}
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long x, y, ax[4], ay[4], by, bx, xx, yy;
bool ok() {
for (int i = 0; i < 4; i++) {
xx = ax[i] - bx;
yy = ay[i] - by;
long long a = abs(x * xx + y * yy);
long long b = abs(y * xx - x * yy);
long long len = abs(x * x + y * y);
if (x == 0 && y == 0) {
if (xx == 0 && yy == 0) return true;
} else if (a % len == 0 && b % len == 0) {
return true;
}
}
return false;
}
int main() {
cin >> ax[0] >> ay[0] >> bx >> by >> x >> y;
for (int i = 1; i < 4; i++) {
ax[i] = ay[i - 1];
ay[i] = -ax[i - 1];
}
if (ok())
printf("YES");
else
printf("NO");
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;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& _p) {
return os << "(" << _p.first << "," << _p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& _V) {
bool f = true;
os << "[";
for (auto v : _V) {
os << (f ? "" : ",") << v;
f = false;
}
return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& _S) {
bool f = true;
os << "(";
for (auto s : _S) {
os << (f ? "" : ",") << s;
f = false;
}
return os << ")";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& _M) {
return os << set<pair<T, U>>(_M.begin(), _M.end());
}
const signed long long INF = 1000000100;
const long double EPS = 1e-9;
signed long long ax, ay, bx, by, cx, cy;
void read_data() { cin >> ax >> ay >> bx >> by >> cx >> cy; }
bool solve() {
if (cx == 0 and cy == 0) {
return (ax == bx and ay == by);
}
signed long long det = cx * cx + cy * cy;
signed long long d1 = bx - ax;
signed long long d2 = by - ay;
signed long long det_p = d1 * cx + d2 * cy;
signed long long det_q = d2 * cx - d1 * cy;
return (det_p % det == 0) and (det_q % det == 0);
}
int main() {
read_data();
bool ok = false;
for (int(_) = (1); (_) <= (4); (_)++) {
signed long long nx = -ay;
signed long long ny = ax;
ax = nx;
ay = ny;
ok |= solve();
}
cout << (ok ? "YES" : "NO") << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
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() {
cin >> ax >> ay >> bx >> by >> cx >> 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";
else
cout << "NO";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool zero(pair<long long, long long> a) { return !a.first && !a.second; }
bool mod(long long a, long long b) {
if (!b)
return a == 0;
else
return a % b == 0;
}
bool judge1(pair<long long, long long> a, pair<long long, long long> b) {
if (!mod(b.first, a.first) || !mod(b.second, a.second)) return false;
long long k1 = -1, k2 = -1;
if (a.first) k1 = b.first / a.first;
if (a.second) k2 = b.second / a.second;
if (k1 != -1 && k2 != -1)
return k1 == k2;
else
return true;
}
bool judge(pair<long long, long long> a, pair<long long, long long> b,
pair<long long, long long> c) {
if (zero(c)) return true;
if (zero(a)) swap(a, b);
if (zero(b)) {
if (zero(a)) return false;
return judge1(c, a);
}
long long tmp = b.first * a.second - a.first * b.second;
long long tmp1 = c.first * a.second - c.second * a.first;
long long tmp2 = c.first * b.second - c.second * b.first;
if (tmp == 0) {
return judge1(c, a) || judge1(c, b);
}
return (tmp2 % tmp == 0 && tmp1 % tmp == 0);
}
pair<long long, long long> rotate(pair<long long, long long> a) {
return make_pair(a.second, -a.first);
}
bool solve(pair<long long, long long> a, pair<long long, long long> b,
pair<long long, long long> c) {
pair<long long, long long> cc = rotate(c);
for (int i = 0; i < 4; i++) {
if (judge(c, cc, make_pair(b.first - a.first, b.second - a.second)))
return true;
a = rotate(a);
}
return false;
}
int main() {
pair<long long, long long> a, b, c;
cin >> a.first >> a.second >> b.first >> b.second >> c.first >> c.second;
if (solve(a, b, c))
puts("YES");
else
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a1, a2, b1, b2, c1, c2;
struct Point {
long long x, y;
Point(long long x = 0, long long y = 0) : x(x), y(y) {}
};
Point ans[5];
int main() {
scanf("%lld %lld %lld %lld %lld %lld", &a1, &a2, &b1, &b2, &c1, &c2);
ans[1] = Point(b1 - a1, b2 - a2);
ans[2] = Point(b1 - a2, b2 + a1);
ans[3] = Point(b1 + a1, b2 + a2);
ans[4] = Point(b1 + a2, b2 - a1);
if (c1 == 0 && c2 == 0) {
for (int i = 1; i <= 4; i++)
if (ans[i].x == 0 && ans[i].y == 0) {
printf("YES\n");
return 0;
}
printf("NO\n");
return 0;
}
for (int i = 1; i <= 4; i++) {
long long t1, t2;
if ((c1 * ans[i].x + c2 * ans[i].y) % (c1 * c1 + c2 * c2) != 0) continue;
if ((c2 * ans[i].x - c1 * ans[i].y) % (c1 * c1 + c2 * c2) != 0) continue;
printf("YES\n");
return 0;
}
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
bool 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;
else
return 0;
} else if (cx == 0) {
long long m = x / cy, n = y / cy;
if (m * cy == x && n * cy == y)
return 1;
else
return 0;
} else if (cy == 0) {
long long m = x / cx, n = y / cx;
if (m * cx == x && n * cx == y)
return 1;
else
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() {
scanf("%lld%lld%lld%lld%lld%lld", &ax, &ay, &bx, &by, &cx, &cy);
bool 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)
cout << "YES\n";
else
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long xa, ya, xb, yb, xc, yc, a, A;
cin >> xa >> ya >> xb >> yb >> xc >> yc;
if ((xa == xb) && (ya == yb))
cout << "YES";
else if ((xb == ya) && (yb == -xa))
cout << "YES";
else if ((xb == -xa) && (yb == -ya))
cout << "YES";
else if ((xb == -ya) && (yb == xa))
cout << "YES";
else if (((xc * xc) + (yc * yc)) == 0)
cout << "NO";
else {
A = (xc * xc) + (yc * yc);
a = (((xb - xa) * xc) + ((yb - ya) * yc));
if (a % A == 0) {
a = a / A;
if ((yc != 0) && ((xb - xa - (xc * a)) % yc == 0)) {
cout << "YES";
return 0;
} else if ((xc != 0) && ((yb - ya - (yc * a)) % xc == 0)) {
cout << "YES";
return 0;
}
}
a = (((xb + ya) * xc) + ((yb - xa) * yc));
if (a % A == 0) {
a = a / A;
if ((yc != 0) && ((xb + ya - (xc * a)) % yc == 0)) {
cout << "YES";
return 0;
} else if ((xc != 0) && ((yb - xa - (yc * a)) % xc == 0)) {
cout << "YES";
return 0;
}
}
a = (((xb + xa) * xc) + ((yb + ya) * yc));
if (a % A == 0) {
a = a / A;
if ((yc != 0) && ((xb + xa - (xc * a)) % yc == 0)) {
cout << "YES";
return 0;
} else if ((xc != 0) && ((yb + ya - (yc * a)) % xc == 0)) {
cout << "YES";
return 0;
}
}
a = (((xb - ya) * xc) + ((yb + xa) * yc));
if (a % A == 0) {
a = a / A;
if ((yc != 0) && ((xb - ya - (xc * a)) % yc == 0)) {
cout << "YES";
return 0;
} else if ((xc != 0) && ((yb + xa - (yc * a)) % xc == 0)) {
cout << "YES";
return 0;
}
}
cout << "NO";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
const int MXN = 1000010;
const int INF = 1000000001;
int n, m;
pair<int, int> A, B, C, D, X;
void test() {
cin >> A.first >> A.second >> B.first >> B.second >> C.first >> C.second;
pair<int, int> obr = A;
int dec = 0;
for (int i = 0; i < 4; i++) {
if (A == B) dec = 1;
int Ax = A.first;
int Ay = A.second;
A.first = -Ay;
A.second = Ax;
}
A = obr;
for (int j = 0; j < 4; j++) {
X.first = B.first - A.first;
X.second = B.second - A.second;
D.first = -C.second;
D.second = C.first;
pair<int, int> ZERO;
ZERO.first = 0;
ZERO.second = 0;
long long int det =
(long long int)C.first * D.second - (long long int)C.second * D.first;
if (det != 0) {
if (det < 0) det = -det;
long long int det2 =
(long long int)X.first * D.second - (long long int)X.second * D.first;
long long int det3 =
(long long int)C.first * X.second - (long long int)C.second * X.first;
if (det2 < 0) det2 = -det2;
if (det3 < 0) det3 = -det3;
if (det2 % det == 0 && det3 % det == 0) dec = 1;
}
pair<int, int> E = A;
A.first = -E.second;
A.second = E.first;
}
if (dec)
printf("YES\n");
else
printf("NO\n");
}
int main() {
int te = 1;
while (te--) test();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[4][2], b[2], c[2][2];
long long x[2], y[2], z[2];
void init() {
a[1][0] = a[0][1];
a[1][1] = -a[0][0];
a[2][0] = -a[0][0];
a[2][1] = -a[0][1];
a[3][0] = -a[0][1];
a[3][1] = a[0][0];
c[1][0] = c[0][1];
c[1][1] = -c[0][0];
}
bool check() {
long long det = x[0] * y[1] - x[1] * y[0];
long long detx = z[0] * y[1] - z[1] * y[0];
long long dety = x[0] * z[1] - x[1] * z[0];
if (det == 0 && detx == 0 && dety == 0)
return true;
else if (det == 0 && (detx != 0 || dety != 0))
return false;
else if (detx % det == 0 && dety % det == 0)
return true;
else
return false;
}
int main() {
cin >> a[0][0] >> a[0][1];
cin >> b[0] >> b[1];
cin >> c[0][0] >> c[0][1];
init();
bool ans = false;
if (c[0][0] == 0 && c[0][1] == 0) {
for (int i = 0; i < 4; i++) {
if (b[0] == a[i][0] && b[1] == a[i][1]) {
ans = true;
break;
}
}
} else {
for (int i = 0; i < 4; i++) {
z[0] = b[0] - a[i][0];
z[1] = b[1] - a[i][1];
x[0] = c[0][0];
x[1] = c[0][1];
y[0] = c[1][0];
y[1] = c[1][1];
if (check()) {
ans = true;
break;
}
}
}
if (ans)
puts("YES");
else
puts("NO");
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
long long x, y;
} A, B, C;
bool judge(long long x, long long y) {
struct node D;
D.x = C.y, D.y = -C.x;
x = B.x - x, y = B.y - y;
if (C.x == 0 && C.y == 0) {
if (x == 0 && y == 0) return 1;
} else if (C.x == 0 && C.y != 0) {
if (x % D.x == 0 && y % C.y == 0) return 1;
} else if (C.x != 0 && C.y == 0) {
if (x % C.x == 0 && y % D.y == 0) return 1;
} else {
long long num2 = D.y * C.x - D.x * C.y;
long long num1 = y * C.x - x * C.y;
if (num2 == 0) {
if (num1 == 0) return 1;
} else {
if (num1 % num2 == 0) {
long long b = num1 / num2;
long long c = x - b * D.x;
if (c % C.x == 0) return 1;
}
}
}
return 0;
}
int main() {
while (cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y) {
bool flag = false;
if (judge(A.x, A.y)) flag = true;
if (judge(A.y, -A.x)) flag = true;
if (judge(-A.x, -A.y)) flag = true;
if (judge(-A.y, A.x)) flag = true;
if (flag == true)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool can(long long x1, long long y1, long long x2, long long y2, long long x3,
long long y3) {
x2 -= x1;
y2 -= y1;
long long a = x2 * x3 + y2 * y3;
long long b = x3 * x3 + y3 * y3;
if (b == 0) {
if (x2 == 0 && y2 == 0) return true;
return false;
}
if (a % b) return false;
a = a / b;
if (y3) {
long long x22 = x2 - a * x3;
if (x22 % y3) return false;
b = x22 / y3;
} else {
if (y2 % x3) return false;
b = -y2 / x3;
}
if (x2 != a * x3 + b * y3) return false;
if (y2 != -b * x3 + a * y3) return false;
return true;
}
int main() {
long long x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
int t = 0;
if (can(x1, y1, x2, y2, x3, y3)) t++;
if (can(y1, -x1, x2, y2, x3, y3)) t++;
if (can(-x1, -y1, x2, y2, x3, y3)) t++;
if (can(-y1, x1, x2, y2, x3, y3)) t++;
if (t)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ax, ay, bx, by, cx, cy;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(void) {
scanf("%d%d%d%d%d%d", &ax, &ay, &bx, &by, &cx, &cy);
if (cx == 0 && cy == 0) {
if ((ax == bx && ay == by) || (ax == -by && ay == bx) ||
(ax == -bx && ay == -by) || (ax == by && ay == -bx))
puts("YES");
else
puts("NO");
return 0;
}
for (int i = 0; i < 4; i++) {
int rx = bx + dx[i] * ax + dy[i] * ay, ry = by + dx[i] * ay - dy[i] * ax;
long long D = -cy * 1LL * cy - cx * 1LL * cx;
long long DX = rx * 1LL * -cx - cy * 1LL * ry;
long long DY = cx * 1LL * ry - rx * 1LL * cy;
if (DX % D == 0 && DY % D == 0) {
puts("YES");
return 0;
}
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long wllabs(long long x) {
if (x < 0)
return -x;
else
return x;
}
bool can(long long x1, long long y1, long long x2, long long y2, long long x0,
long long y0) {
long long A = x2 - x0;
long long B = y2 - y0;
if (A == 0 && B == 0) return true;
long long det = (x1) * (x1) + (y1) * (y1);
if (det == 0) {
return false;
}
long long al = A * x1 + B * y1;
long long be = A * y1 - B * x1;
if (wllabs(al) % det == 0 && wllabs(be) % det == 0) {
return true;
} else {
return false;
}
}
int main() {
long long x1, y1, x2, y2, x0, y0;
cin >> x0 >> y0;
cin >> x2 >> y2;
cin >> x1 >> y1;
bool f1, f2, f3, f4;
f1 = can(x1, y1, x2, y2, x0, y0);
f2 = can(x1, y1, x2, y2, -x0, -y0);
f3 = can(x1, y1, x2, y2, y0, -x0);
f4 = can(x1, y1, x2, y2, -y0, x0);
if (f1 || f2 || f3 || f4)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
long long int mul(long long int a, long long int b) {
return ((a % mod) * (b % mod)) % mod;
}
long long int add(long long int a, long long int b) {
return ((a % mod) + (b % mod)) % mod;
}
long long int sub(long long int a, long long int b) {
return ((a % mod) - (b % mod) + mod) % mod;
}
long long int po(long long int a, long long int b) {
if (b == 0) {
return 1;
}
long long int t = po(a, b / 2);
if (b % 2) {
return mul(t, mul(t, a));
} else {
return mul(t, t);
}
}
long long int x1;
long long int x2;
long long int x3;
long long int yy1;
long long int y2;
long long int y3;
bool f(long long int X, long long int Y) {
long long int d = x3 * x3 + y3 * y3;
long long int dx = X * x3 + Y * y3;
long long int 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() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> x1 >> yy1 >> x2 >> y2 >> x3 >> y3;
long long int m = 8;
while (m--) {
long long int X = x2 - x1, Y = y2 - yy1;
if (f(X, Y)) {
cout << "YES\n";
exit(0);
}
long long int x = yy1, y = -x1;
x1 = x, yy1 = y;
}
cout << "NO\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e15;
const long long int M = 1e9 + 7;
long long int a1, a2, b1, b2, c1, c2;
bool ok;
void Case() {
long long int num = (b1 - a1) * c1 + (b2 - a2) * c2;
long long int den = c1 * c1 + c2 * c2;
if (c1 == 0 && c2 == 0) {
if (num != 0) return;
if (b1 == a1 && b2 == a2) ok = true;
return;
} else {
if (num % den != 0) return;
}
num = (b2 - a2) * c1 - (b1 - a1) * c2;
if (c1 == 0 && c2 == 0) {
if (num != 0) return;
} else {
if (num % den != 0) return;
}
ok = true;
}
void solve() {
cin >> a1 >> a2;
cin >> b1 >> b2;
cin >> c1 >> c2;
ok = false;
Case();
long long int var = a1;
a1 = -a2, a2 = var;
Case();
var = a1, a1 = -a2, a2 = var;
Case();
var = a1, a1 = -a2, a2 = var;
Case();
(ok) ? (cout << "YES") : (cout << "NO");
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
|
#include <bits/stdc++.h>
using namespace std;
long long ax, ay, bx, by, cx, cy;
int solve(long long x2, long long y2) {
if (cx == 0 && cy == 0) {
if (x2 == 0 && y2 == 0) return 1;
return 0;
} else if (cx == 0) {
long long g, h;
g = x2 / cy;
h = y2 / cy;
if (g * cy == x2 && h * cy == y2) return 1;
return 0;
} else if (cy == 0) {
long long g, h;
g = x2 / cx;
h = y2 / cx;
if (g * cx == x2 && h * cx == y2) return 1;
return 0;
} else {
long long a, b;
if ((cx * cy + cx * cx) == 0) return 0;
b = (x2 * cy - y2 * cx) / (cy * cy + cx * cx);
a = (x2 - b * cy) / cx;
if (b * (cy * cy + cx * cx) == (x2 * cy - y2 * cx) &&
(a * cx == x2 - b * cy)) {
return 1;
}
return 0;
}
return 0;
}
int main() {
scanf("%lld%lld", &ax, &ay);
scanf("%lld%lld", &bx, &by);
scanf("%lld%lld", &cx, &cy);
if (solve(bx - ax, by - ay)) {
puts("YES");
return 0;
}
if (solve(bx + ax, by + ay)) {
puts("YES");
return 0;
}
if (solve(bx - ay, by + ax)) {
puts("YES");
return 0;
}
if (solve(bx + ay, by - ax)) {
puts("YES");
return 0;
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
long long x, y;
};
node b, c;
bool Judge(long long x, long long y) {
node a;
a.x = x;
a.y = y;
if (c.x == 0 && c.y == 0) {
if (a.x == b.x && a.y == b.y) return true;
return false;
}
long long k, C;
long long g, h;
g = b.x - a.x;
h = b.y - a.y;
k = g * c.x + h * c.y;
if (k % (c.x * c.x + c.y * c.y) == 0) {
k /= (c.x * c.x + c.y * c.y);
if (c.y != 0) {
C = g - k * c.x;
if (C % c.y == 0) {
return true;
}
return false;
} else {
C = k * c.y - h;
if (C % c.x == 0) {
return true;
}
return false;
}
}
return false;
}
int main() {
node a;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y) {
if (Judge(a.x, a.y) == true) {
puts("YES");
} else if (Judge(-a.y, a.x) == true) {
puts("YES");
} else if (Judge(a.y, -a.x) == true) {
puts("YES");
} else if (Judge(-a.x, -a.y) == true) {
puts("YES");
} else {
puts("NO");
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long Ax, Ay, Bx, By, Cx, Cy;
bool solvable(long long A, long long B) {
return (Cx * A + Cy * B) % (Cx * Cx + Cy * Cy) == 0 &&
(-Cy * A + Cx * B) % (Cx * Cx + Cy * Cy) == 0;
}
bool possible() {
cin >> Ax >> Ay >> Bx >> By >> Cx >> Cy;
if (Cx == 0 && Cy == 0) {
if (Bx == Ax && By == Ay) return true;
if (Bx == Ay && By == -Ax) return true;
if (Bx == -Ax && By == -Ay) return true;
if (Bx == -Ay && By == Ax) return true;
return false;
}
if (solvable(Bx - Ax, By - Ay)) return true;
if (solvable(Bx - Ay, By + Ax)) return true;
if (solvable(Bx + Ax, By + Ay)) return true;
if (solvable(Bx + Ay, By - Ax)) return true;
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << (possible() ? "YES" : "NO") << endl;
cout << flush;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a1, a2, b1, b2, c1, c2;
bool check(long long x, long long y) {
long long d = c1 * c1 + c2 * c2;
if (d == 0) return x == 0 && y == 0;
return (x * c1 + y * c2) % d == 0 && (y * c1 - x * c2) % d == 0;
}
int main() {
cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;
cout << (check(a1 - b1, a2 - b2) || check(a1 + b1, a2 + b2) ||
check(a1 - b2, a2 + b1) || check(a1 + b2, a2 - b1)
? "YES"
: "NO")
<< endl;
}
|
#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 ddx[] = {1, 0, -1, 0};
int ddy[] = {0, -1, 0, 1};
int main() {
int ax, ay, bx, by, cx, cy;
cin >> ax >> ay >> bx >> by >> cx >> cy;
bool ok = false;
for (int i = 0; !ok && i < 4; i++) {
long long dx = bx - (ddx[i] * ax + ddy[i] * ay);
long long dy = by - (ddx[(i + 3) % 4] * ax + ddy[(i + 3) % 4] * ay);
if (cx == 0 && cy == 0) {
ok = dx == 0 && dy == 0;
continue;
}
long long det = 1ll * cx * cx + 1ll * cy * cy;
ok = (dx * cx + dy * cy) % det == 0 && (dx * cy - dy * cx) % det == 0;
}
cout << (ok ? "YES" : "NO") << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
bool check(long long a, long long b, long long c1, long long c2) {
if (a == 0 && b == 0) {
if (c1 == c2 && c1 == 0)
return 1;
else
return 0;
}
long long tt = a * a + b * b;
long long t1 = c1 * a + c2 * b;
long long t2 = a * c2 - b * c1;
if (t1 % tt == 0 && t2 % tt == 0)
return 1;
else
return 0;
}
int main() {
long long a1, a2;
long long b1, b2, c1, c2;
while (scanf("%I64d %I64d", &a1, &a2) != EOF) {
scanf("%I64d %I64d", &b1, &b2);
scanf("%I64d %I64d", &c1, &c2);
bool flag = 0;
if (check(c1, c2, b1 - a1, b2 - a2)) flag = 1;
if (check(c1, c2, b1 + a2, b2 - a1)) flag = 1;
if (check(c1, c2, b1 + a1, b2 + a2)) flag = 1;
if (check(c1, c2, b1 - a2, b2 + a1)) flag = 1;
if (flag)
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool ok(long long int c1, long long int c2, long long int a1,
long long int a2) {
long long int d = c1 * c1 + c2 * c2;
if (d == 0LL) return a1 == 0LL && a2 == 0LL;
return (a1 * c1 + a2 * c2) % d == 0LL && (a1 * c2 - a2 * c1) % d == 0LL;
}
int main() {
int a1, a2, b1, b2, c1, c2;
scanf("%d %d %d %d %d %d", &a1, &a2, &b1, &b2, &c1, &c2);
if (ok(c1, c2, b1 - a1, b2 - a2) || ok(c1, c2, b1 - a2, b2 + a1) ||
ok(c1, c2, b1 + a1, b2 + a2) || ok(c1, c2, b1 + a2, b2 - a1))
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
int main() {
long long x1, y1, x2, y2, x3, y3, tmp, i;
scanf("%I64d %I64d", &x1, &y1);
scanf("%I64d %I64d", &x2, &y2);
scanf("%I64d %I64d", &x3, &y3);
for (i = 0; i < 4; i++) {
long long p = x3 * x3 + y3 * y3;
if (p == 0) {
if (x1 == x2 && y1 == y2) {
puts("YES");
return 0;
}
} else if ((x3 * (x2 - x1) + y3 * (y2 - y1)) % p == 0 &&
(y3 * (x2 - x1) - x3 * (y2 - y1)) % p == 0) {
puts("YES");
return 0;
}
tmp = x1;
x1 = y1;
y1 = -tmp;
}
puts("NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int xc, yc;
long long gcd(long long x, long long y) {
while (x > 0 && y > 0)
if (x > y)
x %= y;
else
y %= x;
return x + y;
}
bool chk(long long x, long long y, long long xa, long long ya, long long xb,
long long yb) {
if (xa == 0 && ya == 0) return (xc == x && yc == y);
x = xc - x;
y = yc - y;
long long t1 = xb * ya - yb * xa;
long long t2 = x * ya - y * xa;
if (t1 == 0) return t2 == 0 && (x % gcd(xa, xb) == 0);
if (t2 % t1 != 0) return false;
long long b = t2 / t1;
if (xa != 0) return ((x - b * xb) % xa) == 0;
return ((y - b * yb) % ya) == 0;
}
bool chk(pair<int, int> x, pair<int, int> a, pair<int, int> b) {
return chk(x.first, x.second, a.first, a.second, b.first, b.second);
}
int main(int argc, char** argv) {
int xa, ya;
int xb, yb;
cin >> xa >> ya >> xc >> yc >> xb >> yb;
vector<pair<int, int> > v1, v2, v3;
v1.push_back(make_pair(xa, ya));
v1.push_back(make_pair(-xa, -ya));
v1.push_back(make_pair(-ya, xa));
v1.push_back(make_pair(ya, -xa));
v2.push_back(make_pair(xb, yb));
v2.push_back(make_pair(-xb, -yb));
v3.push_back(make_pair(-yb, xb));
v3.push_back(make_pair(yb, -xb));
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 2; ++j)
for (int k = 0; k < 2; ++k)
if (chk(v1[i], v2[j], v3[k])) {
cout << "YES" << endl;
return 0;
}
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
long long a, b, x, y, p, q, d;
long long c(long long a, long long b) {
d = p * p + q * q;
if (d == 0) return a == 0 && b == 0;
return (a * p + b * q) % d == 0 && (b * p - a * q) % d == 0;
}
int main() {
std::cin >> a >> b >> x >> y >> p >> q;
std::cout << (c(a - x, b - y) || c(a + x, b + y) || c(a - y, b + x) ||
c(a + y, b - x)
? "YES"
: "NO");
}
|
#include <bits/stdc++.h>
using namespace std;
int sure(long long bx, long by, long long cx, long long cy) {
long long x = bx * cy - by * cx;
long long y = bx * cx + by * cy;
long long z = cx * cx + cy * cy;
if (!z)
return !bx && !by;
else
return (x % z == 0) && (y % z == 0);
}
int main() {
long long ax, ay, bx, by, cx, cy;
cin >> ax >> ay;
cin >> bx >> by;
cin >> cx >> cy;
int flag = 0;
for (int i = 0; i < 4; i++) {
swap(ax, ay);
ax = -ax;
if (sure(bx - ax, by - ay, cx, cy)) flag = 1;
}
if (flag)
printf("YES\n");
else
printf("NO\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void method(long long x1, long long y1, long long x3, long long y3,
long long x2, long long y2) {
x3 -= x1;
y3 -= y1;
if (x2 == 0 && y2 == 0) {
if (x3 == 0 && y3 == 0) {
cout << "YES" << endl;
exit(0);
} else
return;
}
if (x2 == 0) {
swap(x2, y2);
}
if ((y3 * x2 - x3 * y2) % (x2 * x2 + y2 * y2) == 0) {
long long y = (y3 * x2 - x3 * y2) / (x2 * x2 + y2 * y2);
if ((x3 + y * y2) % x2 == 0) {
long long x = (x3 + y * y2) % x2;
cout << "YES" << endl;
exit(0);
}
}
}
int main() {
int x1, y1;
int x2, y2;
int x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
method(x1, y1, x2, y2, x3, y3);
method(-y1, x1, x2, y2, x3, y3);
method(-x1, -y1, x2, y2, x3, y3);
method(y1, -x1, x2, y2, x3, y3);
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
int xa, xb, xc, ya, yb, yc;
bool judge() {
long long x = xc, y = yc, u = xb - xa, v = yb - ya;
if (!u && !v) return 1;
long long f = x * u + y * v, g = x * x + y * y;
if (g == 0 || f % g != 0) return 0;
long long a = f / g;
if (x)
f = v - a * y, g = x;
else
f = u, g = -y;
if (f % g != 0) return 0;
return 1;
}
int main() {
scanf("%d%d%d%d%d%d", &xa, &ya, &xb, &yb, &xc, &yc);
bool flag = 0;
flag |= judge();
std::swap(xb, yb), xb *= -1;
flag |= judge();
std::swap(xb, yb), xb *= -1;
flag |= judge();
std::swap(xb, yb), xb *= -1;
flag |= judge();
printf("%s\n", flag ? "YES" : "NO");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
int ans = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
ans = max(ans, a[i]);
}
for (int i = ans; i < 1000; i++) {
int cur = 0;
for (int j = 0; j < n; j++) {
cur += i - a[j] * 2;
}
if (cur > 0) {
cout << i;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int T, n, mx, val, mxe = 0;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &val);
mx += val;
if (val > mxe) mxe = val;
}
int i = mxe;
while (n * i - mx <= mx) i++;
printf("%d ", i);
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
void bruce(int n, vector<int> v) {
cout << "\nExpected answer:\n";
int k = 0, total = 0, sum = 0;
for (int K = 0; K < n; K++) {
k = max(k, v[K]);
}
for (int K = 0; K < n; K++) total += v[K];
for (int K = 0; K < n; K++) {
v[K] = k - v[K];
sum += v[K];
}
for (int K = k;; K++) {
if (sum > total) {
cout << K << "\n";
break;
}
sum += n;
}
cout << "\nAnswer recieved:\n";
}
void task() {
int n, k = 0, ans, total = 0, sum = 0;
cin >> n;
vector<int> ara(n);
for (int K = 0; K < n; K++) cin >> ara[K];
for (int K = 0; K < n; K++) {
k = max(k, ara[K]);
total += ara[K];
}
for (int K = 0; K < n; K++) {
ara[K] = k - ara[K];
sum += ara[K];
}
if (sum > total) {
cout << k << "\n";
return;
}
ans = (int)(total - sum) / n;
ans++;
ans += k;
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
task();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[222];
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
int sum = 0;
int ma = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
ma = max(ma, a[i]);
}
int ans = 0;
for (int i = ma; i <= 300; i++) {
if (i * n - sum > sum) {
ans = i;
break;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
int N, A[101];
int main() {
ios_base::sync_with_stdio(0);
cout.precision(15);
cout << fixed;
cout.tie(0);
cin.tie(0);
cin >> N;
int mx = 0;
for (int(i) = 1; (i) <= (N); (i)++) {
cin >> A[i];
mx = max(mx, A[i]);
}
for (int(answer) = 1; (answer) <= (1000); (answer)++)
if (answer >= mx) {
int a = 0;
int b = 0;
for (int(i) = 1; (i) <= (N); (i)++) {
a += A[i];
b += answer - A[i];
}
if (a < b) {
cout << answer << '\n';
return 0;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; ++i) cin >> arr[i];
int sum = accumulate((arr).begin(), (arr).end(), 0);
for (int i = *max_element((arr).begin(), (arr).end());; ++i)
if (i * n - sum > sum) {
cout << i;
return 0;
}
return 0;
}
|
#include <bits/stdc++.h>
void seieve();
long long maxx(long long, long long);
long long minn(long long, long long);
using namespace std;
const long long mod = 1000000007;
const long long limits = (long long)1e18;
long long primes[1000001] = {0};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
long long t, i, j = 0, k, n, m, o, p;
cin >> n;
long long a[n], mx = -1;
long long suuum = 0;
for (i = 0; i < n; i++) {
cin >> a[i];
suuum += a[i];
if (a[i] > mx) mx = a[i];
}
for (i = mx; i < 400; i++) {
long long sum = 0;
for (j = 0; j < n; j++) {
sum += i - a[j];
}
if (sum > suuum) {
cout << i << endl;
break;
}
}
return 0;
}
void seieve() {
long long i, p;
primes[0] = 1;
primes[1] = 1;
for (p = 2; p * p <= 1000000; p++) {
if (primes[p] == 0) {
for (i = p * 2; i <= 1000000; i += p) primes[i] = 1;
}
}
}
long long maxx(long long a, long long b) { return (a > b) ? a : b; }
long long minn(long long a, long long b) { return (a < b) ? a : b; }
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, k = 0;
cin >> n;
vector<int> a;
int mx = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
a.push_back(x);
if (x > mx) mx = x;
k += x;
}
int j = mx;
while (true) {
int s = 0;
for (int i = 0; i < n; i++) s += j - a[i];
if (s > k) {
cout << j;
break;
}
j++;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
int amin = a[0], oppV = a[0];
for (int i = 1; i < n; i++) {
if (amin < a[i]) amin = a[i];
oppV = oppV + a[i];
}
long int totalV, k;
for (int j = amin; j < 10000; j++) {
totalV = j * n;
if (totalV - oppV > oppV) {
cout << j;
return 0;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-2;
int n;
int main() {
scanf("%d", &n);
int i, j, a, b;
int num = 0, big = -1;
for (i = 1; i <= n; i++) {
scanf("%d", &a);
num += a;
big = max(big, a);
}
for (i = big;; i++) {
if (i * n - num > num) break;
}
printf("%d", i);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 123;
const long long INF = 1e18 + 123;
const double pi = acos(-1.0);
const long double eps = 1e-9;
int n, a[300000], mx = -1, sum;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i], mx = max(mx, a[i]);
while (1) {
if (sum < mx * n - sum) cout << mx, exit(0);
mx++;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int N, S, ANS;
int main() {
scanf("%d", &N);
for (int i = 0, x; i < N; i++) {
scanf("%d", &x);
S += x, ANS = max(ANS, x);
}
while (ANS * N - S <= S) ANS++;
printf("%d\n", ANS);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int arr[n];
int max = -1;
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] > max) {
max = arr[i];
}
sum += arr[i];
}
int comp_sum = 0;
int tmp = max;
while (comp_sum <= sum) {
for (int i = 0; i < n; i++) {
comp_sum += tmp - arr[i];
}
if (comp_sum <= sum) {
comp_sum = 0;
tmp++;
}
}
printf("%d", tmp);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, i;
cin >> n;
int arr[n], tot = 0, mx = 0;
for (i = 0; i < n; i++) {
cin >> arr[i];
tot += arr[i];
mx = max(mx, arr[i]);
}
mx--;
int tot2 = 0;
while (tot2 <= tot) {
mx++;
tot2 = 0;
for (i = 0; i < n; i++) {
tot2 += mx - arr[i];
}
}
cout << mx << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> A(n);
for (int i = 0; i < n; ++i) cin >> A[i];
for (int k = *max_element(A.begin(), A.end());; ++k) {
int getv = 0;
for (int i = 0; i < n; ++i) {
getv += k - A[i];
}
if (getv > accumulate(A.begin(), A.end(), 0)) cout << k << '\n', exit(0);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const int N = 1e5 + 5, inf = 1e9 + 5;
long long add(long long x, long long y) {
x += y;
if (x >= MOD) return x - MOD;
return x;
}
long long sub(long long x, long long y) {
x -= y;
if (x < 0) return x + MOD;
return x;
}
long long mult(long long x, long long y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
int sum = 0;
for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
i += 1 - 2 * ((0) > (n))) {
cin >> a[i];
sum += a[i];
}
int maxx = *max_element(begin(a), end(a));
for (__typeof(205) k = (maxx) - ((maxx) > (205));
k != (205) - ((maxx) > (205)); k += 1 - 2 * ((maxx) > (205))) {
int new_sum = 0;
for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
i += 1 - 2 * ((0) > (n))) {
new_sum += k - a[i];
}
if (new_sum > sum) {
cout << k << endl;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a, sum, mx;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
if (mx < a) mx = a;
sum += a;
}
for (int i = mx;; i++) {
if (i * n - sum > sum) {
cout << i;
return 0;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int s = 0, maxa = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
s += a;
maxa = max(maxa, a);
}
cout << max(maxa, 2 * s / n + 1);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> v(n);
int mx = 0;
for (auto& it : v) {
cin >> it;
mx = max(mx, it);
}
for (int i = mx;; i++) {
int tot = 0, temp = 0;
for (int j = 0; j < n; j++) {
tot += v[j];
temp += i - v[j];
}
if (temp > tot) {
cout << i << "\n";
break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n;
cin >> n;
int a[n], m = 0, s = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
m = max(m, a[i]);
s += a[i];
}
int i;
for (i = m;; i++) {
int c = 0;
for (int j = 0; j < n; j++) {
c += (i - a[j]);
}
if (c > s) break;
}
cout << i << '\n';
}
|
#include <bits/stdc++.h>
using namespace std;
int omadliRaqamlarSoni(int n);
int main(int argc, char** argv) {
int n, a, sum = 0, max = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
if (a > max) {
max = a;
}
sum += a;
}
if (2 * sum / n + 1 >= max) {
cout << 2 * sum / n + 1;
} else {
cout << max;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Solution {
void RunTest(size_t test_id) {
int n;
cin >> n;
vector<int64_t> v(n);
int64_t mx = 0;
for (int i = 0; i < n; ++i) {
cin >> v[i];
mx = max(mx, v[i]);
}
int64_t a = 0, b = 0;
for (int i = 0; i < n; ++i) {
a += v[i];
b += mx - v[i];
}
while (a >= b) {
b += n;
++mx;
}
cout << mx << endl;
}
};
int main() {
std::ios_base::sync_with_stdio(false);
constexpr size_t t = 1;
Solution executor;
for (size_t i = 0; i < t; ++i) {
executor.RunTest(i);
}
}
|
#include <bits/stdc++.h>
int main() {
int n, k, i;
int students[100];
int Awruk = 0, Elodreip = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &students[i]);
}
int biggest_vote = students[0];
for (i = 0; i < n; i++) {
if (students[i] > biggest_vote) {
biggest_vote = students[i];
}
}
for (k = biggest_vote; k < 202; k++) {
for (i = 0; i < n; i++) {
Elodreip = Elodreip + students[i];
Awruk = Awruk + (k - students[i]);
}
if (Awruk > Elodreip) break;
Awruk = 0, Elodreip = 0;
}
printf("%d\n", k);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int k;
int max = 0, sum = 0;
int key;
for (int i = 0; i < n; i++) {
cin >> k;
if (k >= max) {
max = k;
}
sum += k;
}
for (int i = 1; i <= 300; i++) {
if ((i * n - sum) > sum && i >= max) {
key = i;
break;
}
}
cout << key << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, s, ma;
int a[N];
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i], s += a[i], ma = max(ma, a[i]);
while (ma * n <= s * 2) ma++;
cout << ma;
}
|
#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto& x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n;
cin >> n;
long long k_min = 0;
long long sum_votes = 0;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
k_min = max(a[i], k_min);
sum_votes += a[i];
}
long long res = (sum_votes * 2) / n;
res++;
res = max(res, k_min);
cout << res;
cout << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[105], amax, s;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
s += a[i];
amax = max(amax, a[i]);
}
for (int i = amax;; i++) {
if (n * i - s > s) {
cout << i;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[1009];
bool check1(int num, int sum, int n) {
int tsum = 0;
for (int i = 0; i < n; ++i) {
if (arr[i] > num) return false;
tsum = tsum + (num - arr[i]);
}
if (tsum > sum)
return true;
else
return false;
}
int main() {
int n, i, sum = 0;
scanf("%d", &n);
for (i = 0; i < n; ++i) scanf("%d", &arr[i]);
for (i = 0; i < n; ++i) sum += arr[i];
sort(arr, arr + n);
int ml = 2 * arr[n - 1] + 1;
int ms = arr[0];
int ans = -1;
for (i = ms; i <= ml; ++i) {
if (check1(i, sum, n)) {
ans = i;
break;
}
}
printf("%d", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int max = 0, sum = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
if (a > max) max = a;
sum += a;
}
int min = 2 * sum / n + 1;
if (max < min)
cout << min;
else
cout << max;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int N = 200005;
vector<long long int> graph[N];
long long int level[N];
long long int subtree[N];
bool vis[N];
void dfs(long long int curr) {
vis[curr] = 1;
long long int size = 0;
for (auto x : graph[curr]) {
if (!vis[x]) {
level[x] = level[curr] + 1;
dfs(x);
size += subtree[x];
}
}
subtree[curr] = 1 + size;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t = 1;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
long long int sum = 0;
long long int mx = INT_MIN;
for (long long int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
mx = max(mx, a[i]);
}
long long int sum2 = 0;
long long int x = mx;
while (sum2 <= sum) {
sum2 = 0;
for (long long int i = 0; i < n; i++) {
sum2 += (x - a[i]);
}
x++;
}
cout << x - 1 << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
long long n, k, sum2, sum1;
int main() {
cin >> n;
int arr[n];
int maxi = INT_MIN;
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum2 += arr[i];
maxi = max(maxi, arr[i]);
}
k = maxi;
while (true) {
sum1 = 0;
for (int i = 0; i < n; i++) sum1 += k - arr[i];
if (sum1 > sum2)
break;
else
k++;
}
cout << k << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
int maxn = *max_element(a, a + n);
int ans = 0;
for (int i = 0; i < n; i++) ans += (maxn - a[i]);
int sum = 0;
for (int i = 0; i < n; i++) sum += a[i];
while (ans <= sum) {
ans = 0;
for (int i = 0; i < n; i++) ans += (maxn - a[i]);
if (ans > sum) break;
maxn++;
}
cout << maxn << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a;
int main() {
cin >> a;
int b = 0, sum = 0;
for (int i = 0; i < a; i++) {
int n;
cin >> n;
sum += n;
if (n > b) b = n;
}
while ((a * b) - sum <= sum) b++;
cout << b << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long n, e = 0, aw = 0, k = 0;
cin >> n;
long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
k = max(a[i], k);
e += a[i];
}
aw = k * n - e;
while (aw <= e) {
k++;
aw = k * n - e;
}
cout << k;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
int n, mx = 0;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
mx = max(mx, a[i]);
}
for (int i = mx; i <= 300; i++) {
int s = 0;
for (int j = 0; j < n; j++) {
s += i - a[j];
s -= a[j];
}
if (s > 0) {
cout << i << endl;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
x = 0;
char ch = getchar();
while (!isdigit(ch)) ch = getchar();
while (isdigit(ch)) {
x = x * 10 + ch - 48;
ch = getchar();
}
}
int main() {
int n, a, s = 0, cc = 0;
read(n);
for (int i = 0; i < n; i++) {
read(a);
s += a;
cc = max(cc, a);
}
for (int i = cc; i; i++) {
if (i * n - s > s) {
cout << i << endl;
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, t = 0, i, sum = 0;
while (cin >> n) {
int a[1005];
for (i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] >= t) t = a[i];
sum += a[i];
}
for (i = t;; i++)
if (i * n - sum > sum) {
cout << i << endl;
break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[107], r, max1;
bool f(int x) {
if ((n * x) - r > r) return true;
return false;
}
int haha(int b, int e) {
int mid;
while (b <= e) {
mid = (b + e) >> 1;
if (b >= e) {
return mid;
} else if (f(mid))
e = mid;
else
b = mid + 1;
}
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
max1 = max(max1, a[i]);
r += a[i];
}
cout << haha(max1, 10000) << endl;
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void solve() {
long long int n;
cin >> n;
long long int a[n], sum = 0, mx = 0;
for (int(i) = (0); (i) < (n); ++(i)) {
cin >> a[i];
sum += a[i];
mx = max(mx, a[i]);
}
cout << max(mx, 2 * sum / n + 1) << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int mx = 0, sum = 0;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
int a;
scanf("%d", &a);
mx = max(mx, a);
sum += a;
}
sum *= 2;
sum += n;
sum /= n;
printf("%d", max(sum, mx));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int arr[n], sum = 0, ans = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
ans = max(ans, arr[i]);
}
int mine = 0;
for (int i = 0; i < n; i++) {
mine += (ans - arr[i]);
}
while (mine <= sum) {
ans++;
mine += n;
}
cout << ans << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cas = 1;
int dxx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dyy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
struct node {
int x, y;
bool operator<(const node& p) const { return x < p.x; }
};
int main() {
int n;
scanf("%d", &n);
int sum = 0;
int a[105];
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
sort(a, a + n);
int x = a[n - 1];
for (;; x++) {
int g = 0;
for (int i = 0; i < n; i++) {
g += (x - a[i]);
}
if (g > sum) {
printf("%d\n", x);
return 0;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int i, j, k, s, d, r, m, n, mx;
cin >> n;
s = 0;
mx = 0;
for (i = 1; i <= n; i++) {
cin >> r;
v.push_back(r);
s += r;
mx = max(r, mx);
}
for (i = mx; i <= 250; i++) {
d = 0;
for (j = 0; j < n; j++) {
d += (i - v[j]);
}
if (d > s) break;
}
cout << i << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void FAST() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
int main() {
FAST();
long long n;
cin >> n;
long long sum = 0;
long long mn = -1;
for (long long i = 0; i < n; i++) {
long long temp;
cin >> temp;
sum += temp;
mn = max(mn, temp);
}
cout << max(mn, (2 * sum) / n + 1) << endl;
return 0;
}
struct Query {
long long L, R, idx;
};
bool compare(long long a0, long long a1) { return (a0 > a1); }
long long power(long long x, long long y, long long p) {
long long ans = 1;
x = x % p;
while (y > 0) {
if (y & 1) ans = (ans * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return ans;
}
long long x, y, g;
void extendedEuclid(long long a, long long b) {
if (b == 0) {
g = a;
x = 1;
y = 0;
} else {
extendedEuclid(b, a % b);
long long temp = x;
x = y;
y = temp - (a / b) * y;
}
}
long long moduloInverse(long long a, long long p) {
extendedEuclid(a, p);
if (g == 1 && p != 1)
return (x + p) % p;
else
return -1;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum = 0, max = -1;
cin >> n;
int* arr = new int[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] > max) max = arr[i];
sum += arr[i];
}
int k = 2 * sum / n + 1;
if (k < max) k = max;
cout << k;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e8;
const int MAXN = 2e5 + 5;
const long long INFLL = 1e18;
int n, k;
int a[MAXN];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]), k = max(k, a[i]);
while (1) {
int acum = 0;
for (int j = 0; j < n; j++) acum += k - a[j];
if (acum > n * k / 2) break;
k++;
}
printf("%d\n", k);
return 0;
}
|
#include <bits/stdc++.h>
int solve(int n, int S) {
int k = ((2 * S) / n) + 1;
assert(n * k - S > S);
assert(n * (k - 1) - S <= S);
return k;
}
int main() {
int n;
scanf("%d", &n);
int mx = -1;
int S = 0;
for (int i = 0; i < n; ++i) {
int t;
scanf("%d", &t);
S += t;
mx = std::max(mx, t);
}
printf("%d\n", std::max(mx, solve(n, S)));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int sum = 0, max = 0;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) {
sum = sum + a[i];
if (a[i] > max) max = a[i];
}
while (true) {
int s = 0;
for (int i = 0; i < n; i++) {
s = s - a[i] + max;
}
if (s > sum) {
cout << max << endl;
break;
} else
max++;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.