buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
|
|---|---|---|---|---|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
double x1, y1, x2, y2, x3, y3, xp, yp, xg, yg;
StringTokenizer st;
while ((line = br.readLine()) != null && !line.isEmpty()) {
st = new StringTokenizer(line);
x1 = Double.parseDouble(st.nextToken());
y1 = Double.parseDouble(st.nextToken());
x2 = Double.parseDouble(st.nextToken());
y2 = Double.parseDouble(st.nextToken());
x3 = Double.parseDouble(st.nextToken());
y3 = Double.parseDouble(st.nextToken());
xp = Double.parseDouble(st.nextToken());
yp = Double.parseDouble(st.nextToken());
xg = (x1 + x2 + x3) / 3;
yg = (y1 + y2 + y3) / 3;
boolean b = true;
b &=
(linear(x1, y1, x2, y2, xp, yp) * linear(x1, y1, x2, y2, xg, yg) > 0);
b &=
(linear(x2, y2, x3, y3, xp, yp) * linear(x2, y2, x3, y3, xg, yg) > 0);
b &=
(linear(x3, y3, x2, y1, xp, yp) * linear(x3, y3, x1, y1, xg, yg) > 0);
if (b)
System.out.println("YES");
else
System.out.println("NO");
}
}
static double linear(double x1, double y1, double x2, double y2, double xp,
double yp) {
return (y2 - y1) * xp - (x2 - x1) * yp + y2 * (x2 - x1) - x2 * (y2 - y1);
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
double x1, y1, x2, y2, x3, y3, xp, yp, xg, yg;
StringTokenizer st;
while ((line = br.readLine()) != null && !line.isEmpty()) {
st = new StringTokenizer(line);
x1 = Double.parseDouble(st.nextToken());
y1 = Double.parseDouble(st.nextToken());
x2 = Double.parseDouble(st.nextToken());
y2 = Double.parseDouble(st.nextToken());
x3 = Double.parseDouble(st.nextToken());
y3 = Double.parseDouble(st.nextToken());
xp = Double.parseDouble(st.nextToken());
yp = Double.parseDouble(st.nextToken());
xg = (x1 + x2 + x3) / 3;
yg = (y1 + y2 + y3) / 3;
boolean b = true;
b &=
(linear(x1, y1, x2, y2, xp, yp) * linear(x1, y1, x2, y2, xg, yg) > 0);
b &=
(linear(x2, y2, x3, y3, xp, yp) * linear(x2, y2, x3, y3, xg, yg) > 0);
b &=
(linear(x3, y3, x1, y1, xp, yp) * linear(x3, y3, x1, y1, xg, yg) > 0);
if (b)
System.out.println("YES");
else
System.out.println("NO");
}
}
static double linear(double x1, double y1, double x2, double y2, double xp,
double yp) {
return (y2 - y1) * xp - (x2 - x1) * yp + y2 * (x2 - x1) - x2 * (y2 - y1);
}
}
|
[["-", 0, 16, 31, 16, 31, 492, 3, 4, 0, 22], ["+", 0, 16, 31, 16, 31, 492, 3, 4, 0, 22]]
| 3
| 448
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double x1, x2, x3, y1, y2, y3, ax, by, g1, g2, g3;
while (sc.hasNext()) {
x1 = sc.nextDouble();
y1 = sc.nextDouble();
x2 = sc.nextDouble();
y2 = sc.nextDouble();
x3 = sc.nextDouble();
y3 = sc.nextDouble();
ax = sc.nextDouble();
by = sc.nextDouble();
g1 = (x3 - x2) * (by - x2) - (y3 - y2) * (ax - y2);
g2 = (x1 - x3) * (by - x3) - (y1 - y3) * (ax - y3);
g3 = (x2 - x1) * (by - x1) - (y2 - y1) * (ax - y1);
if ((g1 >= 0 & g2 >= 0 & g3 >= 0) | (g1 < 0 & g2 < 0 & g3 < 0)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double x1, x2, x3, y1, y2, y3, ax, by, g1, g2, g3;
while (sc.hasNext()) {
x1 = sc.nextDouble();
y1 = sc.nextDouble();
x2 = sc.nextDouble();
y2 = sc.nextDouble();
x3 = sc.nextDouble();
y3 = sc.nextDouble();
ax = sc.nextDouble();
by = sc.nextDouble();
g1 = (x3 - x2) * (by - y2) - (y3 - y2) * (ax - x2);
g2 = (x1 - x3) * (by - y3) - (y1 - y3) * (ax - x3);
g3 = (x2 - x1) * (by - y1) - (y2 - y1) * (ax - x1);
if ((g1 >= 0 & g2 >= 0 & g3 >= 0) | (g1 < 0 & g2 < 0 & g3 < 0)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
|
[["-", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["-", 12, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 16, 12, 16, 12, 23, 0, 16, 12, 22]]
| 3
| 267
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x1, y1, x2, y2, x3, y3;
double px, py;
double s, ps1, ps2, ps3;
double ep = 0.0001;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&px, &py) != EOF) {
s = fabs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0;
ps1 = fabs(x1 * (y2 - py) + x2 * (py - y1) + px * (y1 - y2)) / 2.0;
ps2 = fabs(px * (y2 - y3) + x2 * (y3 - py) + x3 * (py - y2)) / 2.0;
ps3 = fabs(x1 * (py - y3) + px * (y3 - y1) + x3 * (y1 - py)) / 2.0;
if ((double)abs((s - (ps1 + ps2 + ps3))) < ep) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x1, y1, x2, y2, x3, y3;
double px, py;
double s, ps1, ps2, ps3;
double ep = 0.0001;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&px, &py) != EOF) {
s = fabs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0;
ps1 = fabs(x1 * (y2 - py) + x2 * (py - y1) + px * (y1 - y2)) / 2.0;
ps2 = fabs(px * (y2 - y3) + x2 * (y3 - py) + x3 * (py - y2)) / 2.0;
ps3 = fabs(x1 * (py - y3) + px * (y3 - y1) + x3 * (y1 - py)) / 2.0;
if (fabs((s - (ps1 + ps2 + ps3))) < ep) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 0, 57, 15, 23, 0, 16, 31, 74, 0, 24], ["-", 15, 23, 0, 16, 31, 74, 39, 77, 39, 40], ["-", 0, 57, 15, 23, 0, 16, 31, 74, 0, 25], ["-", 15, 23, 0, 16, 31, 74, 51, 2, 63, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 2, 63, 22]]
| 0
| 250
|
#include <stdio.h>
int a(double A, double a, double B, double b, double x, double y) {
if (A != B) {
return ((a - b) / (A - B)) * (x - A) + a - y;
} else {
return x - A;
}
}
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
int i, j;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
if ((a(x1, y1, x2, y2, xp, yp) * a(x1, y1, x2, y2, x3, y3) < 0) ||
(a(x3, y3, x2, y2, xp, yp) * a(x3, y3, x2, y2, x1, y1) < 0) ||
(a(x1, y1, x3, y3, xp, yp) * a(x1, y1, x3, y3, x2, y2) < 0)) {
printf("NO\n");
} else {
printf("YES\n");
}
}
return 0;
}
|
#include <stdio.h>
double a(double A, double a, double B, double b, double x, double y) {
if (A != B) {
return ((a - b) / (A - B)) * (x - A) + a - y;
} else {
return x - A;
}
}
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
int i, j;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
if ((a(x1, y1, x2, y2, xp, yp) * a(x1, y1, x2, y2, x3, y3) < 0) ||
(a(x3, y3, x2, y2, xp, yp) * a(x3, y3, x2, y2, x1, y1) < 0) ||
(a(x1, y1, x3, y3, xp, yp) * a(x1, y1, x3, y3, x2, y2) < 0)) {
printf("NO\n");
} else {
printf("YES\n");
}
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
| 0
| 260
|
#include <math.h>
#include <stdio.h>
#define DBL(a) ((a) * (a))
#define EPS 1e-8
int main() {
char buf[256];
double x1, y1, x2, y2, x3, y3, xp, yp;
double s, a, b, c, p1, p2, p3;
double sur[4];
int i;
while (fgets(buf, 256, stdin)) {
sscanf(buf, "%lf%lf%lf%lf%lf%lf%lf%lf", &x3, &y1, &x2, &y2, &x3, &y3, &xp,
&yp);
a = sqrt(DBL(x2 - x3) + DBL(y2 - y3));
b = sqrt(DBL(x3 - x1) + DBL(y3 - y1));
c = sqrt(DBL(x1 - x2) + DBL(y1 - y2));
p1 = sqrt(DBL(xp - x1) + DBL(yp - y1));
p2 = sqrt(DBL(xp - x2) + DBL(yp - y2));
p3 = sqrt(DBL(xp - x3) + DBL(yp - y3));
s = (a + b + c) / 2;
sur[0] = sqrt(s * (s - a) * (s - b) * (s - c));
s = (a + p2 + p3) / 2;
sur[1] = sqrt(s * (s - a) * (s - p2) * (s - p3));
s = (b + p3 + p1) / 2;
sur[2] = sqrt(s * (s - b) * (s - p3) * (s - p1));
s = (c + p1 + p2) / 2;
sur[3] = sqrt(s * (s - c) * (s - p1) * (s - p2));
if (sur[1] + sur[2] + sur[3] - sur[0] < EPS)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
#define DBL(a) ((a) * (a))
#define EPS 1e-8
int main() {
char buf[256];
double x1, y1, x2, y2, x3, y3, xp, yp;
double s, a, b, c, p1, p2, p3;
double sur[4];
int i;
while (fgets(buf, 256, stdin)) {
sscanf(buf, "%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp);
a = sqrt(DBL(x2 - x3) + DBL(y2 - y3));
b = sqrt(DBL(x3 - x1) + DBL(y3 - y1));
c = sqrt(DBL(x1 - x2) + DBL(y1 - y2));
p1 = sqrt(DBL(xp - x1) + DBL(yp - y1));
p2 = sqrt(DBL(xp - x2) + DBL(yp - y2));
p3 = sqrt(DBL(xp - x3) + DBL(yp - y3));
s = (a + b + c) / 2;
sur[0] = sqrt(s * (s - a) * (s - b) * (s - c));
s = (a + p2 + p3) / 2;
sur[1] = sqrt(s * (s - a) * (s - p2) * (s - p3));
s = (b + p3 + p1) / 2;
sur[2] = sqrt(s * (s - b) * (s - p3) * (s - p1));
s = (c + p1 + p2) / 2;
sur[3] = sqrt(s * (s - c) * (s - p1) * (s - p2));
if (sur[1] + sur[2] + sur[3] - sur[0] < EPS)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22]]
| 0
| 430
|
#include <stdio.h>
double CrossProduct3(double x1, double y1, double x2, double y2, double x3,
double y3);
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
double Crs1, Crs2, Crs3;
/* ????????§?±??????? */
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
Crs1 = CrossProduct3(x1, y1, x2, y2, xp, yp);
Crs2 = CrossProduct3(x2, y2, x3, y3, xp, yp);
Crs3 = CrossProduct3(x3, y3, x1, y1, xp, yp);
if ((Crs1 > 0 && Crs2 > 0 && Crs3 > 0) ||
(Crs1 < 0 && Crs2 < 0 && Crs3 < 0)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
double CrossProduct3(double x1, double y1, double x2, double y2, double px,
double py) {
double ax, ay, bx, by;
ax = x2 - x1;
ay = y2 - y1;
bx = px - x1;
by = py - x1;
return ax * by - ay * bx;
}
|
#include <stdio.h>
double CrossProduct3(double x1, double y1, double x2, double y2, double x3,
double y3);
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
double Crs1, Crs2, Crs3;
/* ????????§?±??????? */
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
Crs1 = CrossProduct3(x1, y1, x2, y2, xp, yp);
Crs2 = CrossProduct3(x2, y2, x3, y3, xp, yp);
Crs3 = CrossProduct3(x3, y3, x1, y1, xp, yp);
if ((Crs1 > 0 && Crs2 > 0 && Crs3 > 0) ||
(Crs1 < 0 && Crs2 < 0 && Crs3 < 0)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
double CrossProduct3(double x1, double y1, double x2, double y2, double px,
double py) {
double ax, ay, bx, by;
ax = x2 - x1;
ay = y2 - y1;
bx = px - x1;
by = py - y1;
return ax * by - ay * bx;
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
| 0
| 263
|
#include <stdio.h>
int calc(double *base, double *des, double *p) {
double a[2] = {des[0] - base[0], des[1] - base[1]};
double b[2] = {p[0] - base[0], p[1] - base[1]};
return a[0] * b[1] - a[1] * b[0];
}
int main(void) {
double A[2], B[2], C[2], P[2], ans1, ans2, ans3;
for (; ~scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &A[0], &A[1], &B[0], &B[1],
&C[0], &C[1], &P[0], &P[1]);) {
ans1 = calc(A, B, P), ans2 = calc(B, C, P), ans3 = calc(C, A, P);
if ((ans1 < 0 && ans2 < 0 && ans3 < 0) ||
(ans1 >= 0 && ans2 >= 0 && ans3 >= 0))
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <stdio.h>
double calc(double *base, double *des, double *p) {
double a[2] = {des[0] - base[0], des[1] - base[1]};
double b[2] = {p[0] - base[0], p[1] - base[1]};
return a[0] * b[1] - a[1] * b[0];
}
int main(void) {
double A[2], B[2], C[2], P[2], ans1, ans2, ans3;
for (; ~scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &A[0], &A[1], &B[0], &B[1],
&C[0], &C[1], &P[0], &P[1]);) {
ans1 = calc(A, B, P), ans2 = calc(B, C, P), ans3 = calc(C, A, P);
if ((ans1 < 0 && ans2 < 0 && ans3 < 0) ||
(ans1 >= 0 && ans2 >= 0 && ans3 >= 0))
puts("YES");
else
puts("NO");
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
| 0
| 273
|
#include <stdio.h>
int main(void) {
double x1, x2, x3, xp, y1, y2, y3, yp, key, key12, key23, key13;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
if (x2 < x1 && x1 < x3) {
key = x1;
x1 = x2;
x2 = key;
key = y1;
y1 = y2;
y2 = key;
} else if (x2 < x3 && x3 < x1) {
key = x3;
x3 = x1;
x1 = x2;
x2 = key;
key = y3;
y3 = y1;
y1 = y2;
y2 = key;
} else if (x3 < x1 && x1 < x2) {
key = x1;
x1 = x3;
x3 = x2;
x2 = key;
key = y1;
y1 = y3;
y3 = y2;
y2 = key;
} else if (x3 < x2 && x2 < x1) {
key = x1;
x1 = x3;
x3 = key;
key = y1;
y1 = y3;
y3 = key;
} else if (x1 < x3 && x3 < x2) {
key = x3;
x3 = x2;
x2 = key;
key = y3;
y3 = y2;
y2 = key;
}
if (xp <= x1)
printf("NO\n");
else if (x3 <= xp)
printf("NO\n");
else if (x1 < xp && xp <= x2) {
key12 = (y2 - y1) * (xp - x1) / (x2 - x1) + y1;
key13 = (y3 - y1) * (xp - x1) / (x3 - x1) + y1;
if (key12 > key13) {
if (key13 < yp && yp < key12)
printf("YES\n");
else
printf("NO\n");
} else if (key13 > key12) {
if (key13 > yp && yp > key12)
printf("YES\n");
else
printf("NO\n");
} else
printf("NO\n");
} else if (x2 < xp && xp < x3) {
key23 = (y3 - y2) * (xp - x2) / (x3 - x2) + y2;
key13 = (y3 - y1) * (xp - x1) / (x3 - x1) * y1;
if (key23 > key13) {
if (key13 < yp && yp < key23)
printf("YES\n");
else
printf("NO\n");
} else if (key23 < key13) {
if (key13 > yp && yp > key23)
printf("YES\n");
else
printf("NO\n");
} else
printf("NO\n");
} else
printf("NO\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
double x1, x2, x3, xp, y1, y2, y3, yp, key, key12, key23, key13;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
if (x2 < x1 && x1 < x3) {
key = x1;
x1 = x2;
x2 = key;
key = y1;
y1 = y2;
y2 = key;
} else if (x2 < x3 && x3 < x1) {
key = x3;
x3 = x1;
x1 = x2;
x2 = key;
key = y3;
y3 = y1;
y1 = y2;
y2 = key;
} else if (x3 < x1 && x1 < x2) {
key = x1;
x1 = x3;
x3 = x2;
x2 = key;
key = y1;
y1 = y3;
y3 = y2;
y2 = key;
} else if (x3 < x2 && x2 < x1) {
key = x1;
x1 = x3;
x3 = key;
key = y1;
y1 = y3;
y3 = key;
} else if (x1 < x3 && x3 < x2) {
key = x3;
x3 = x2;
x2 = key;
key = y3;
y3 = y2;
y2 = key;
}
if (xp <= x1)
printf("NO\n");
else if (x3 <= xp)
printf("NO\n");
else if (x1 < xp && xp <= x2) {
key12 = (y2 - y1) * (xp - x1) / (x2 - x1) + y1;
key13 = (y3 - y1) * (xp - x1) / (x3 - x1) + y1;
/*printf("%lf %lf\n", key12,key13);*/
if (key12 > key13) {
if (key13 < yp && yp < key12)
printf("YES\n");
else
printf("NO\n");
} else if (key13 > key12) {
if (key13 > yp && yp > key12)
printf("YES\n");
else
printf("NO\n");
} else
printf("NO\n");
} else if (x2 < xp && xp < x3) {
key23 = (y3 - y2) * (xp - x2) / (x3 - x2) + y2;
key13 = (y3 - y1) * (xp - x1) / (x3 - x1) + y1;
/*printf("b%lf %lf\n", key23, key13);*/
if (key23 > key13) {
if (key13 < yp && yp < key23)
printf("YES\n");
else
printf("NO\n");
} else if (key23 < key13) {
if (key13 > yp && yp > key23)
printf("YES\n");
else
printf("NO\n");
} else
printf("NO\n");
} else
printf("NO\n");
}
return 0;
}
|
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72]]
| 0
| 586
|
#include <stdio.h>
int line(double x1, double y1, double x2, double y2, double *a, double *b);
int main() {
double ax, ay, bx, by, cx, cy, px, py;
double aa, ab, ba, bb, ca, cb;
int swch;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &ax, &ay, &bx, &by, &cx, &cy,
&px, &py) != EOF) {
if (1 == line(ax, ay, bx, by, &ca,
&cb)) { /*xÀWª¯¶¾Á½ê*/
swch = ((ax < cx) == (ax < px));
}
if (((cx * ca + cb) > cy) == ((px * ca + cb) > px) || swch) {
swch = 0;
if (1 == line(bx, by, cx, cy, &aa, &ab)) {
swch = ((bx > ax) == (bx > px));
}
if (((ax * aa + ab) > ay) == ((px * aa + ab) > py) || swch) {
swch = 0;
if (1 == line(cx, cy, ax, ay, &ba, &bb)) {
swch = ((cx < bx) == (cx < px));
}
if (((bx * ba + bb) > by) == (px * ba + bb) > py || swch) {
printf("YES\n");
continue;
}
}
}
printf("NO\n");
}
return 0;
}
int line(double x1, double y1, double x2, double y2, double *a, double *b) {
if (x1 == x2) {
return 1;
} else {
*a = (y1 - y2) / (x1 - x2);
*b = y1 - (*a * x1);
}
return 0;
}
|
#include <stdio.h>
int line(double x1, double y1, double x2, double y2, double *a, double *b);
int main() {
double ax, ay, bx, by, cx, cy, px, py;
double aa, ab, ba, bb, ca, cb;
int swch;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &ax, &ay, &bx, &by, &cx, &cy,
&px, &py) != EOF) {
swch = 0;
if (1 == line(ax, ay, bx, by, &ca,
&cb)) { /*xÀWª¯¶¾Á½ê*/
swch = ((ax < cx) == (ax < px));
}
if (((cx * ca + cb) > cy) == ((px * ca + cb) > py) /*|| ((px*ca+cb)==px)*/
|| swch) { /*((px*ca+cb)>px)->((px*ca+cb)>py)*/
swch = 0; /*((px*ca+cb)==px)->ȵ*/
if (1 == line(bx, by, cx, cy, &aa, &ab)) {
swch = ((bx > ax) == (bx > px));
}
if (((ax * aa + ab) > ay) == ((px * aa + ab) > py) /*|| ((px*aa+ab)==py)*/
|| swch) {
swch = 0;
if (1 == line(cx, cy, ax, ay, &ba, &bb)) {
swch = ((cx < bx) == (cx < px));
}
if (((bx * ba + bb) > by) == (px * ba + bb) > py /*|| (px*ba+bb)==py*/
|| swch) {
printf("YES\n");
continue;
}
}
}
printf("NO\n");
}
return 0;
}
int line(double x1, double y1, double x2, double y2, double *a, double *b) {
if (x1 == x2) {
return 1;
} else {
*a = (y1 - y2) / (x1 - x2);
*b = y1 - (*a * x1);
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
| 0
| 406
|
// AOJ Volume 0 Problem 0012
#include <math.h>
#include <stdio.h>
typedef struct {
double x1;
double y1;
double x2;
double y2;
} LINE;
int cross(LINE *l1, LINE *l2) {
double ta, tb, tc, td;
// ta=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1)
// tb=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2)
// tc=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3)
// td=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4)
ta = (l2->x1 - l2->x2) * (l1->y1 - l2->y1) +
(l2->y1 - l2->y2) * (l2->x1 - l1->x1);
tb = (l2->x1 - l2->x2) * (l1->y2 - l2->y1) +
(l2->y1 - l2->y2) * (l2->x1 - l1->x2);
tc = (l1->x1 - l1->x2) * (l2->y1 - l1->y1) +
(l1->y1 - l1->y2) * (l1->x1 - l2->x1);
td = (l1->x1 - l1->x2) * (l2->y2 - l1->y1) +
(l1->y1 - l1->y2) * (l1->x1 - l2->x2);
if ((ta * tb < 0) && (tc * td < 0)) {
return (1);
}
return (0);
}
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
double xg, yg;
LINE a, b, c, x;
int flag;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
xg = (x1 + x2 + x3) / 3.0;
yg = (y1 + y2 + y3) / 3.0;
a.x1 = x1;
a.y1 = y1;
a.x2 = x2;
a.y2 = y2;
b.x1 = x2;
b.y1 = y2;
b.x2 = x3;
b.y2 = y3;
c.x1 = x3;
c.y1 = y3;
c.x2 = x1;
c.y2 = y1;
x.x1 = xp;
x.y1 = yp;
x.x2 = xg;
x.y2 = yg;
flag = cross(&a, &x);
flag += cross(&b, &x);
flag += cross(&b, &x);
if (flag == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return (0);
}
|
// AOJ Volume 0 Problem 0012
#include <math.h>
#include <stdio.h>
typedef struct {
double x1;
double y1;
double x2;
double y2;
} LINE;
int cross(LINE *l1, LINE *l2) {
double ta, tb, tc, td;
// ta=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1)
// tb=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2)
// tc=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3)
// td=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4)
ta = (l2->x1 - l2->x2) * (l1->y1 - l2->y1) +
(l2->y1 - l2->y2) * (l2->x1 - l1->x1);
tb = (l2->x1 - l2->x2) * (l1->y2 - l2->y1) +
(l2->y1 - l2->y2) * (l2->x1 - l1->x2);
tc = (l1->x1 - l1->x2) * (l2->y1 - l1->y1) +
(l1->y1 - l1->y2) * (l1->x1 - l2->x1);
td = (l1->x1 - l1->x2) * (l2->y2 - l1->y1) +
(l1->y1 - l1->y2) * (l1->x1 - l2->x2);
// ta = (l2->x2 - l2->x1) * (l1->y1 - l2->y1) + (l2->y2 - l2->y1) * (l1->x1
//- l2->x1); tb = (l2->x2 - l2->x1) * (l1->y2 - l2->y1) + (l2->y2 - l2->y1) *
//(l1->x2 - l2->x1);
// tc = (l1->x2 - l1->x1) * (l2->y1 - l1->y1) + (l1->y2 - l1->y1) * (l2->x1
//- l1->x1); td = (l1->x2 - l1->x1) * (l2->y2 - l1->y1) + (l1->y2 - l1->y1) *
//(l2->x2 - l1->x1);
if ((ta * tb <= 0) && (tc * td <= 0)) {
return (1);
}
return (0);
}
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
double xg, yg;
LINE a, b, c, x;
int flag;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
xg = (x1 + x2 + x3) / 3.0;
yg = (y1 + y2 + y3) / 3.0;
a.x1 = x1;
a.y1 = y1;
a.x2 = x2;
a.y2 = y2;
b.x1 = x2;
b.y1 = y2;
b.x2 = x3;
b.y2 = y3;
c.x1 = x3;
c.y1 = y3;
c.x2 = x1;
c.y2 = y1;
x.x1 = xp;
x.y1 = yp;
x.x2 = xg;
x.y2 = yg;
flag = cross(&a, &x);
flag += cross(&b, &x);
flag += cross(&c, &x);
if (flag == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return (0);
}
|
[["-", 15, 23, 0, 16, 31, 23, 0, 16, 17, 18], ["+", 15, 23, 0, 16, 31, 23, 0, 16, 17, 19], ["-", 15, 23, 0, 16, 12, 23, 0, 16, 17, 18], ["+", 15, 23, 0, 16, 12, 23, 0, 16, 17, 19], ["-", 0, 11, 12, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 66, 28, 22]]
| 0
| 510
|
#include <math.h>
#include <stdio.h>
int main() {
double x[5], y[5], d[9], s, s1, s2;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x[0], &y[0], &x[1], &y[1], &x[2],
&y[2], &x[3], &y[3]) != EOF) {
d[0] = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
d[1] = sqrt((x[2] - x[1]) * (x[2] - x[1]) + (y[2] - y[1]) * (y[2] - y[1]));
d[2] = sqrt((x[2] - x[0]) * (x[2] - x[0]) + (y[2] - y[0]) * (y[2] - y[0]));
d[3] = sqrt((x[3] - x[0]) * (x[3] - x[0]) + (y[3] - y[0]) * (y[3] - y[0]));
d[4] = sqrt((x[3] - x[1]) * (x[3] - x[1]) + (y[3] - y[1]) * (y[3] - y[1]));
d[5] = sqrt((x[3] - x[2]) * (x[3] - x[2]) + (y[3] - y[2]) * (y[3] - y[2]));
s1 = s2 = 0.0;
s = (d[0] + d[1] + d[2]) / 2;
s1 += sqrt(s * (s - d[0]) * (s - d[1]) * (s - d[2]));
s = (d[0] + d[3] + d[4]) / 2;
s2 += sqrt(s * (s - d[0]) * (s - d[3]) * (s - d[4]));
s = (d[1] + d[4] + d[5]) / 2;
s2 += sqrt(s * (s - d[1]) * (s - d[4]) * (s - d[5]));
s = (d[2] + d[5] + d[3]) / 2;
s2 += sqrt(s * (s - d[2]) * (s - d[5]) * (s - d[3]));
// printf("%lf\n%lf\n",s1,s2);
if (s2 > s1)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main() {
double x[5], y[5], d[9], s, s1, s2;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x[0], &y[0], &x[1], &y[1], &x[2],
&y[2], &x[3], &y[3]) != EOF) {
d[0] = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
d[1] = sqrt((x[2] - x[1]) * (x[2] - x[1]) + (y[2] - y[1]) * (y[2] - y[1]));
d[2] = sqrt((x[2] - x[0]) * (x[2] - x[0]) + (y[2] - y[0]) * (y[2] - y[0]));
d[3] = sqrt((x[3] - x[0]) * (x[3] - x[0]) + (y[3] - y[0]) * (y[3] - y[0]));
d[4] = sqrt((x[3] - x[1]) * (x[3] - x[1]) + (y[3] - y[1]) * (y[3] - y[1]));
d[5] = sqrt((x[3] - x[2]) * (x[3] - x[2]) + (y[3] - y[2]) * (y[3] - y[2]));
s1 = s2 = 0.0;
s = (d[0] + d[1] + d[2]) / 2;
s1 += sqrt(s * (s - d[0]) * (s - d[1]) * (s - d[2]));
s = (d[0] + d[3] + d[4]) / 2;
s2 += sqrt(s * (s - d[0]) * (s - d[3]) * (s - d[4]));
s = (d[1] + d[4] + d[5]) / 2;
s2 += sqrt(s * (s - d[1]) * (s - d[4]) * (s - d[5]));
s = (d[2] + d[5] + d[3]) / 2;
s2 += sqrt(s * (s - d[2]) * (s - d[5]) * (s - d[3]));
// printf("%lf\n%lf\n",s1,s2);
if (s2 - s1 > 0.000001)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 33], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 682
|
#include <math.h>
#include <stdio.h>
#define SQ(x) (x) * (x)
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
int main(void) {
double x[4], y[4], S, s, a, b, c, sum;
while (~scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[1], &y[1], &x[2], &y[2],
&x[3], &y[3], &x[0], &y[0])) {
sum = 0;
a = sqrt(SQ(x[1] - x[2]) + SQ(y[1] - y[2]));
b = sqrt(SQ(x[3] - x[2]) + SQ(y[3] - y[2]));
c = sqrt(SQ(x[1] - x[3]) + SQ(y[1] - y[3]));
s = (a + b + c) / 2;
S = sqrt(s * (s - a) * (s - b) * (s - c));
a = sqrt(SQ(x[0] - x[2]) + SQ(y[0] - y[2]));
b = sqrt(SQ(x[3] - x[2]) + SQ(y[3] - y[2]));
c = sqrt(SQ(x[0] - x[3]) + SQ(y[0] - y[3]));
s = (a + b + c) / 2;
sum += sqrt(s * (s - a) * (s - b) * (s - c));
a = sqrt(SQ(x[1] - x[0]) + SQ(y[1] - y[0]));
b = sqrt(SQ(x[3] - x[0]) + SQ(y[3] - y[0]));
c = sqrt(SQ(x[1] - x[3]) + SQ(y[1] - y[3]));
s = (a + b + c) / 2;
sum += sqrt(s * (s - a) * (s - b) * (s - c));
a = sqrt(SQ(x[1] - x[2]) + SQ(y[1] - y[2]));
b = sqrt(SQ(x[0] - x[2]) + SQ(y[0] - y[2]));
c = sqrt(SQ(x[1] - x[0]) + SQ(y[1] - y[0]));
s = (a + b + c) / 2;
sum += sqrt(s * (s - a) * (s - b) * (s - c));
if (EQ(S, sum))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
#define SQ(x) (x) * (x)
#define EPS (1e-10)
#define EQ(a, b) (fabs((a) - (b)) < EPS)
int main(void) {
double x[4], y[4], S, s, a, b, c, sum;
while (~scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x[1], &y[1], &x[2], &y[2],
&x[3], &y[3], &x[0], &y[0])) {
sum = 0;
a = sqrt(SQ(x[1] - x[2]) + SQ(y[1] - y[2]));
b = sqrt(SQ(x[3] - x[2]) + SQ(y[3] - y[2]));
c = sqrt(SQ(x[1] - x[3]) + SQ(y[1] - y[3]));
s = (a + b + c) / 2;
S = sqrt(s * (s - a) * (s - b) * (s - c));
a = sqrt(SQ(x[0] - x[2]) + SQ(y[0] - y[2]));
b = sqrt(SQ(x[3] - x[2]) + SQ(y[3] - y[2]));
c = sqrt(SQ(x[0] - x[3]) + SQ(y[0] - y[3]));
s = (a + b + c) / 2;
sum += sqrt(s * (s - a) * (s - b) * (s - c));
a = sqrt(SQ(x[1] - x[0]) + SQ(y[1] - y[0]));
b = sqrt(SQ(x[3] - x[0]) + SQ(y[3] - y[0]));
c = sqrt(SQ(x[1] - x[3]) + SQ(y[1] - y[3]));
s = (a + b + c) / 2;
sum += sqrt(s * (s - a) * (s - b) * (s - c));
a = sqrt(SQ(x[1] - x[2]) + SQ(y[1] - y[2]));
b = sqrt(SQ(x[0] - x[2]) + SQ(y[0] - y[2]));
c = sqrt(SQ(x[1] - x[0]) + SQ(y[1] - y[0]));
s = (a + b + c) / 2;
sum += sqrt(s * (s - a) * (s - b) * (s - c));
if (EQ(S, sum))
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
| 0
| 664
|
#include <stdio.h>
int main() {
int ans = 0;
float x1, y1, x2, y2, x3, y3, x, y;
for (; ~scanf("%f%f%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3, &x, &y);) {
if (((x2 - x1) * (y - y1) - (y2 - y1) * (x - x1)) < 0)
ans--;
else
ans++;
if (((x3 - x2) * (y - y2) - (y3 - y2) * (x - x2)) < 0)
ans--;
else
ans++;
if (((x1 - x3) * (y - y3) - (y1 - y3) * (x - x3)) < 0)
ans--;
else
ans++;
if (ans == 3 || ans == -3)
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <stdio.h>
int main() {
int ans = 0;
float x1, y1, x2, y2, x3, y3, x, y;
for (; ~scanf("%f%f%f%f%f%f%f%f", &x1, &y1, &x2, &y2, &x3, &y3, &x, &y);) {
ans = 0;
if (((x2 - x1) * (y - y1) - (y2 - y1) * (x - x1)) < 0)
ans--;
else
ans++;
if (((x3 - x2) * (y - y2) - (y3 - y2) * (x - x2)) < 0)
ans--;
else
ans++;
if (((x1 - x3) * (y - y3) - (y1 - y3) * (x - x3)) < 0)
ans--;
else
ans++;
if (ans == 3 || ans == -3)
puts("YES");
else
puts("NO");
}
return 0;
}
|
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
| 0
| 207
|
#include <stdio.h>
#define intersect(x1, y1, x2, y2) \
(((x1 - x2) * (yp - y1) + (y1 - y2) * (x1 - xp)) * \
((x1 - x2) * (yc - y1) + (y1 - y2) * (x1 - xc)) < \
0)
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
double xc, yc;
xc = (x1 + x2 + x3) / 3;
xc = (y1 + y2 + y3) / 3;
if (intersect(x1, y1, x2, y2) || intersect(x2, y2, x3, y3) ||
intersect(x3, y3, x1, y1))
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
// refered to #513648 by ytetsuwo
|
#include <stdio.h>
#define intersect(x1, y1, x2, y2) \
(((x1 - x2) * (yp - y1) + (y1 - y2) * (x1 - xp)) * \
((x1 - x2) * (yc - y1) + (y1 - y2) * (x1 - xc)) < \
0)
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
double xc, yc;
xc = (x1 + x2 + x3) / 3;
yc = (y1 + y2 + y3) / 3;
if (intersect(x1, y1, x2, y2) || intersect(x2, y2, x3, y3) ||
intersect(x3, y3, x1, y1))
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
// refered to #513648 by ytetsuwo
|
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22]]
| 0
| 161
|
#include <math.h>
#include <stdio.h>
int S(double a, double b, double c) {
double s = (a + b + c) / 2;
return sqrt(s * (s - a) * (s - b) * (s - c));
}
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp, a, b, c, xa, xb, xc;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
a = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
b = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
c = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2));
xa = sqrt(pow(x3 - xp, 2) + pow(y3 - yp, 2));
xb = sqrt(pow(x2 - xp, 2) + pow(y2 - yp, 2));
xc = sqrt(pow(x1 - xp, 2) + pow(y1 - yp, 2));
if (S(a, xb, xc) + S(b, xc, xa) + S(c, xa, xb) - S(a, b, c) > 0.0000001) {
puts("NO");
} else {
puts("YES");
}
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
double S(double a, double b, double c) {
double s = (a + b + c) / 2;
return sqrt(s * (s - a) * (s - b) * (s - c));
}
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp, a, b, c, xa, xb, xc;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
a = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
b = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
c = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2));
xa = sqrt(pow(x3 - xp, 2) + pow(y3 - yp, 2));
xb = sqrt(pow(x2 - xp, 2) + pow(y2 - yp, 2));
xc = sqrt(pow(x1 - xp, 2) + pow(y1 - yp, 2));
if (S(a, xb, xc) + S(b, xc, xa) + S(c, xa, xb) - S(a, b, c) > 0.0000001) {
puts("NO");
} else {
puts("YES");
}
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40]]
| 0
| 328
|
#include <stdio.h>
struct point {
float x;
float y;
};
struct point sub(struct point a, struct point b) {
struct point ret;
ret.x = a.x - b.x;
ret.y = a.y - b.y;
return ret;
}
int is_in(struct point a, struct point b, struct point c, struct point p) {
struct point ab, bp, bc, cp, ca, ap;
float c1, c2, c3;
ab = sub(a, b);
bp = sub(p, b);
bc = sub(c, b);
cp = sub(p, c);
ca = sub(a, c);
ap = sub(p, a);
c1 = ab.x * bp.y - ab.y * bp.x;
c2 = bc.x * cp.y - bc.y * cp.x;
c3 = ca.x * ap.y - ca.y * ap.x;
if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) {
return 1;
} else {
return 0;
}
}
int main(void) {
float x1, y1, x2, y2, x3, y3, xp, xy;
struct point p1, p2, p3, p4;
while (scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&xy) != EOF) {
p1.x = x1;
p1.y = y1;
p2.x = x2;
p2.y = y2;
p3.x = x3;
p3.y = y3;
p4.x = xp;
p4.y = xy;
if (is_in(p1, p2, p3, p4)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
#include <stdio.h>
struct point {
float x;
float y;
};
struct point sub(struct point a, struct point b) {
struct point ret;
ret.x = a.x - b.x;
ret.y = a.y - b.y;
return ret;
}
int is_in(struct point a, struct point b, struct point c, struct point p) {
struct point ab, bp, bc, cp, ca, ap;
float c1, c2, c3;
ab = sub(b, a);
bp = sub(p, b);
bc = sub(c, b);
cp = sub(p, c);
ca = sub(a, c);
ap = sub(p, a);
c1 = ab.x * bp.y - ab.y * bp.x;
c2 = bc.x * cp.y - bc.y * cp.x;
c3 = ca.x * ap.y - ca.y * ap.x;
if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) {
return 1;
} else {
return 0;
}
}
int main(void) {
float x1, y1, x2, y2, x3, y3, xp, xy;
struct point p1, p2, p3, p4;
while (scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&xy) != EOF) {
p1.x = x1;
p1.y = y1;
p2.x = x2;
p2.y = y2;
p3.x = x3;
p3.y = y3;
p4.x = xp;
p4.y = xy;
if (is_in(p1, p2, p3, p4)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
| 0
| 405
|
// includes
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
using namespace std;
// types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
// solve
double x[4], y[4];
double calc(int i, int j, int k) {
return 0.5 *
abs((x[j] - x[i]) * (y[k] - x[i]) - (x[k] - x[i]) * (y[j] - y[i]));
}
int main(int argc, char const *argv[]) {
while (cin >> x[0]) {
cin >> y[0];
FOR(i, 1, 4) { cin >> x[i] >> y[i]; }
double area = calc(0, 1, 2);
double tmp = calc(0, 1, 3) + calc(0, 2, 3) + calc(1, 2, 3);
if (abs(area - tmp) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
// includes
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
using namespace std;
// types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
// solve
double x[4], y[4];
double calc(int i, int j, int k) {
return 0.5 *
abs((x[j] - x[i]) * (y[k] - y[i]) - (x[k] - x[i]) * (y[j] - y[i]));
}
int main(int argc, char const *argv[]) {
while (cin >> x[0]) {
cin >> y[0];
FOR(i, 1, 4) { cin >> x[i] >> y[i]; }
double area = calc(0, 1, 2);
double tmp = calc(0, 1, 3) + calc(0, 2, 3) + calc(1, 2, 3);
if (abs(area - tmp) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 31, 16, 12, 23, 0, 16, 12, 69, 28, 22], ["+", 31, 16, 12, 23, 0, 16, 12, 69, 28, 22]]
| 1
| 332
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
struct vector2D {
double x, y;
vector2D(double x, double y) {
this->x = x;
this->y = y;
}
};
vector2D vec(double ax, double ay, double bx, double by) {
return vector2D(bx - ax, by - ax);
}
double outer(vector2D a, vector2D b) { return a.x * b.y - a.y * b.x; }
int main() {
vector<double> x(3);
vector<double> y(3);
double xp, yp;
for (; cin >> x.at(0) >> y.at(0) >> x.at(1) >> y.at(1) >> x.at(2) >>
y.at(2) >> xp >> yp;) {
vector2D ab = vec(x.at(1), y.at(1), x.at(0), y.at(0));
vector2D bc = vec(x.at(2), y.at(2), x.at(1), y.at(1));
vector2D ca = vec(x.at(0), y.at(0), x.at(2), y.at(2));
vector2D ap = vec(xp, yp, x.at(0), y.at(0));
vector2D bp = vec(xp, yp, x.at(1), y.at(1));
vector2D cp = vec(xp, yp, x.at(2), y.at(2));
if ((outer(ab, bp) >= 0 && outer(bc, cp) >= 0 && outer(ca, ap) >= 0) ||
(outer(ab, bp) <= 0 && outer(bc, cp) <= 0 && outer(ca, ap) <= 0)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
struct vector2D {
double x, y;
vector2D(double x, double y) {
this->x = x;
this->y = y;
}
};
vector2D vec(double ax, double ay, double bx, double by) {
return vector2D(bx - ax, by - ay);
}
double outer(vector2D a, vector2D b) { return a.x * b.y - a.y * b.x; }
int main() {
vector<double> x(3);
vector<double> y(3);
double xp, yp;
for (; cin >> x.at(0) >> y.at(0) >> x.at(1) >> y.at(1) >> x.at(2) >>
y.at(2) >> xp >> yp;) {
vector2D ab = vec(x.at(1), y.at(1), x.at(0), y.at(0));
vector2D bc = vec(x.at(2), y.at(2), x.at(1), y.at(1));
vector2D ca = vec(x.at(0), y.at(0), x.at(2), y.at(2));
vector2D ap = vec(xp, yp, x.at(0), y.at(0));
vector2D bp = vec(xp, yp, x.at(1), y.at(1));
vector2D cp = vec(xp, yp, x.at(2), y.at(2));
if ((outer(ab, bp) >= 0 && outer(bc, cp) >= 0 && outer(ca, ap) >= 0) ||
(outer(ab, bp) <= 0 && outer(bc, cp) <= 0 && outer(ca, ap) <= 0)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
[["-", 0, 37, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 12, 22]]
| 1
| 451
|
#include <complex>
#include <iostream>
#include <vector>
using namespace std;
typedef complex<double> cd;
#define X real()
#define Y imag()
double dot(cd a, cd b) { return (a * conj(b)).X; }
double cross(cd a, cd b) { return -((a * conj(b)).Y); }
int main() {
double x, y;
while (cin >> x >> y) {
vector<cd> v, vec;
v.push_back(cd(x, y));
for (int i = 1; i < 3; i++) {
cin >> x >> y;
v.push_back(cd(x, y));
}
v.push_back(v[0]);
for (int i = 0; i < 3; i++) {
vec.push_back(v[i + 1] - v[i]);
}
cin >> x >> y;
int all_p = 1, all_n = 1;
for (int i = 0; i < 3; i++) {
int crs = cross(vec[i], cd(x, y) - v[i]);
all_p &= crs > 0;
all_n &= crs < 0;
}
if (all_p || all_n) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <complex>
#include <iostream>
#include <vector>
using namespace std;
typedef complex<double> cd;
#define X real()
#define Y imag()
double dot(cd a, cd b) { return (a * conj(b)).X; }
double cross(cd a, cd b) { return -((a * conj(b)).Y); }
int main() {
double x, y;
while (cin >> x >> y) {
vector<cd> v, vec;
v.push_back(cd(x, y));
for (int i = 1; i < 3; i++) {
cin >> x >> y;
v.push_back(cd(x, y));
}
v.push_back(v[0]);
for (int i = 0; i < 3; i++) {
vec.push_back(v[i + 1] - v[i]);
}
cin >> x >> y;
int all_p = 1, all_n = 1;
for (int i = 0; i < 3; i++) {
double crs = cross(vec[i], cd(x, y) - v[i]);
all_p &= crs > 0;
all_n &= crs < 0;
}
if (all_p || all_n) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40]]
| 1
| 286
|
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)
#define EPS (1e-10)
class P { //???
public:
double x, y;
P(double _x = 0, double _y = 0) : x(_x), y(_y){};
P operator+(P &p) { return P(x + p.x, y + p.y); } //??????
P operator-(P &p) { return P(x - p.x, y - p.y); } //??????
P operator*(double k) { return P(x * k, y * k); } //??????
P operator/(double k) { return P(x / k, y / k); } //??????
bool operator==(const P &p) {
return (fabs(x - p.x) < EPS && fabs(y - p.y) < EPS);
}
// bool operator < (const P &p)const{ return ( x!=p.x ? x<p.x:y<p.y ); }
double norm() { return x * x + y * y; } //?????????
double abs() { return sqrt(norm()); } //??§??????
};
struct L {
P p1, p2;
}; //??´???
typedef vector<P> Polygon; //????§???¢
typedef P Vector; //????????????
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
int ccw(P p0, P p1, P p2) { // AOJ_BOOK_P386 verified
Vector a = p1 - p0;
Vector b = p2 - p0;
if (cross(a, b) > EPS)
return 1; // COUNTER_CLOCKWISE
if (cross(a, b) < -EPS)
return -1; // CLOCKWISE
if (dot(a, b) < -EPS)
return 2; // ONLINE_BACK
if (a.norm() < b.norm())
return -2; // ONLINE_FRONT
return 0; // ON_SEGMENT;
}
//?????????????????? verified
bool intersect(P p1, P p2, P p3, P p4) {
return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
//????????¨???????????¢ verified ARC042-B
double distance_l_p(L l, P p) {
return abs(cross(l.p2 - l.p1, p - l.p1)) / (l.p2 - l.p1).abs();
}
//????????¨??????????????????(????????£???????????´??????????????±???)
bool intersect_circle_point(P center, double r, L line) {
if (distance_l_p(line, center) <= r + EPS)
return true;
return false;
}
//????´?????§???¢??????
bool isSimple(Polygon pol) {
//???????????????????????????pol?????\????????????
size_t pol_size = pol.size() - 1;
rep(i, pol_size) {
for (int j = i + 2; j < pol_size; j++) {
if (i == j || i == (j - 1 + pol_size) % pol_size ||
i == (j + 1 + pol_size) % pol_size)
continue;
if (intersect(pol[i], pol[i + 1], pol[j], pol[j + 1]))
return false;
}
}
return true;
}
//?????????????§???¢????????´?????????????????????????±??????? true???????????´
//verified AOJ0012
bool isPointInsidePolygon(vector<L> side, P p) {
int c = 0, sideSum = side.size();
rep(i, sideSum) {
if (cross(side[i].p2 - side[i].p1, p - side[i].p1))
c++;
}
return !(c % sideSum);
}
int main() {
double a, b, c, d, e, f, g, h;
while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
vector<L> angle;
angle.pb(L{P(a, b), P(c, d)});
angle.pb(L{P(c, d), P(e, f)});
angle.pb(L{P(e, f), P(a, b)});
if (isPointInsidePolygon(angle, P(g, h))) {
cout << "YES" << endl;
} else
cout << "NO" << endl;
}
return 0;
}
|
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)
#define EPS (1e-10)
class P { //???
public:
double x, y;
P(double _x = 0, double _y = 0) : x(_x), y(_y){};
P operator+(P &p) { return P(x + p.x, y + p.y); } //??????
P operator-(P &p) { return P(x - p.x, y - p.y); } //??????
P operator*(double k) { return P(x * k, y * k); } //??????
P operator/(double k) { return P(x / k, y / k); } //??????
bool operator==(const P &p) {
return (fabs(x - p.x) < EPS && fabs(y - p.y) < EPS);
}
// bool operator < (const P &p)const{ return ( x!=p.x ? x<p.x:y<p.y ); }
double norm() { return x * x + y * y; } //?????????
double abs() { return sqrt(norm()); } //??§??????
};
struct L {
P p1, p2;
}; //??´???
typedef vector<P> Polygon; //????§???¢
typedef P Vector; //????????????
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
int ccw(P p0, P p1, P p2) { // AOJ_BOOK_P386 verified
Vector a = p1 - p0;
Vector b = p2 - p0;
if (cross(a, b) > EPS)
return 1; // COUNTER_CLOCKWISE
if (cross(a, b) < -EPS)
return -1; // CLOCKWISE
if (dot(a, b) < -EPS)
return 2; // ONLINE_BACK
if (a.norm() < b.norm())
return -2; // ONLINE_FRONT
return 0; // ON_SEGMENT;
}
//?????????????????? verified
bool intersect(P p1, P p2, P p3, P p4) {
return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
//????????¨???????????¢ verified ARC042-B
double distance_l_p(L l, P p) {
return abs(cross(l.p2 - l.p1, p - l.p1)) / (l.p2 - l.p1).abs();
}
//????????¨??????????????????(????????£???????????´??????????????±???)
bool intersect_circle_point(P center, double r, L line) {
if (distance_l_p(line, center) <= r + EPS)
return true;
return false;
}
//????´?????§???¢??????
bool isSimple(Polygon pol) {
//???????????????????????????pol?????\????????????
size_t pol_size = pol.size() - 1;
rep(i, pol_size) {
for (int j = i + 2; j < pol_size; j++) {
if (i == j || i == (j - 1 + pol_size) % pol_size ||
i == (j + 1 + pol_size) % pol_size)
continue;
if (intersect(pol[i], pol[i + 1], pol[j], pol[j + 1]))
return false;
}
}
return true;
}
//?????????????§???¢????????´?????????????????????????±??????? true???????????´
//verified AOJ0012
bool isPointInsidePolygon(vector<L> side, P p) {
int c = 0, sideSum = side.size();
rep(i, sideSum) {
if (cross(side[i].p2 - side[i].p1, p - side[i].p1) > 0)
c++;
}
return !(c % sideSum);
}
int main() {
double a, b, c, d, e, f, g, h;
while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
vector<L> angle;
angle.pb(L{P(a, b), P(c, d)});
angle.pb(L{P(c, d), P(e, f)});
angle.pb(L{P(e, f), P(a, b)});
if (isPointInsidePolygon(angle, P(g, h))) {
cout << "YES" << endl;
} else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 918
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define swap(a, b) tmp = ver[b], ver[b] = ver[a], ver[a] = tmp;
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
double p, q, r;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
p = (x2 - x1) * (yp - x1) - (y2 - y1) * (xp - x1);
q = (x3 - x2) * (yp - x2) - (y3 - y2) * (xp - x2);
r = (x1 - x3) * (yp - x3) - (y1 - y3) * (xp - x3);
if (p * q > 0 && q * r > 0 && r * p > 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define swap(a, b) tmp = ver[b], ver[b] = ver[a], ver[a] = tmp;
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
double p, q, r;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
p = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
q = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
r = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);
if (p * q > 0 && q * r > 0 && r * p > 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 22]]
| 1
| 204
|
#include <algorithm>
#include <array>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
using namespace std;
typedef long long Int;
#define REP(i, x) for (int i = 0; i < x; ++i)
typedef pair<int, int> P;
struct point {
double x, y;
};
bool Func(point p1, point p2, point p3) {
double x1 = p2.x - p1.x;
double y1 = p2.y - p1.y;
double x2 = p3.x - p2.x;
double y2 = p3.y - p2.y;
return (x1 * y2 - x2 * y1) > 0;
}
int main() {
point p1, p2, p3, p4;
while (cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y) {
string ans = (Func(p1, p2, p4) > 0 && Func(p2, p3, p4) > 0 &&
Func(p3, p1, p4) > 0) ||
(Func(p1, p2, p4) < 0 && Func(p2, p3, p4) < 0 &&
Func(p3, p1, p4) < 0)
? "YES"
: "NO";
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <array>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
using namespace std;
typedef long long Int;
#define REP(i, x) for (int i = 0; i < x; ++i)
typedef pair<int, int> P;
struct point {
double x, y;
};
double Func(point p1, point p2, point p3) {
double x1 = p2.x - p1.x;
double y1 = p2.y - p1.y;
double x2 = p3.x - p2.x;
double y2 = p3.y - p2.y;
return (x1 * y2 - x2 * y1);
}
int main() {
point p1, p2, p3, p4;
while (cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y) {
string ans = (Func(p1, p2, p4) > 0 && Func(p2, p3, p4) > 0 &&
Func(p3, p1, p4) > 0) ||
(Func(p1, p2, p4) < 0 && Func(p2, p3, p4) < 0 &&
Func(p3, p1, p4) < 0)
? "YES"
: "NO";
cout << ans << endl;
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 47], ["-", 0, 14, 8, 9, 0, 37, 0, 16, 12, 13]]
| 1
| 268
|
#include <iostream>
using namespace std;
typedef struct myvector {
double x;
double y;
} Vector;
Vector sub_vector(Vector &a, Vector &b) {
Vector ret;
ret.x = b.x - a.x;
ret.y = b.y - a.y;
return ret;
}
double cross_product(Vector &a, Vector &b) { return a.x * b.y - b.x * a.y; }
int main() {
Vector A, B, C, P;
while (cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> P.x >> P.y) {
Vector AC = sub_vector(A, C);
Vector CB = sub_vector(C, B);
Vector BA = sub_vector(B, A);
Vector AP = sub_vector(A, P);
Vector CP = sub_vector(C, P);
Vector BP = sub_vector(B, P);
if ((cross_product(AP, AC) > 0 && cross_product(CP, CB) > 0 &&
cross_product(BP, BA)) ||
(cross_product(AP, AC) < 0 && cross_product(CP, CB) < 0 &&
cross_product(BP, BA) < 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <iostream>
using namespace std;
typedef struct myvector {
double x;
double y;
} Vector;
Vector sub_vector(Vector &a, Vector &b) {
Vector ret;
ret.x = b.x - a.x;
ret.y = b.y - a.y;
return ret;
}
double cross_product(Vector &a, Vector &b) { return a.x * b.y - b.x * a.y; }
int main() {
Vector A, B, C, P;
while (cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> P.x >> P.y) {
Vector AC = sub_vector(A, C);
Vector CB = sub_vector(C, B);
Vector BA = sub_vector(B, A);
Vector AP = sub_vector(A, P);
Vector CP = sub_vector(C, P);
Vector BP = sub_vector(B, P);
if ((cross_product(AP, AC) > 0 && cross_product(CP, CB) > 0 &&
cross_product(BP, BA) > 0) ||
((cross_product(AP, AC) < 0 && cross_product(CP, CB) < 0 &&
cross_product(BP, BA) < 0)))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["+", 51, 16, 31, 23, 0, 16, 12, 16, 17, 47], ["+", 51, 16, 31, 23, 0, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 15, 339, 51, 16, 12, 23, 0, 23, 0, 25]]
| 1
| 280
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define bit(i) static_cast<bitset<8>>(i)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int>> minpq;
struct edge {
int to, cost;
};
void begin() {
cin.tie(0);
ios::sync_with_stdio(false);
};
int gcd(int a, int b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
};
int lcm(int m, int n) {
if ((0 == m) || (0 == n)) {
return 0;
}
return ((m / gcd(m, n)) * n);
};
unsigned long long comb(long n, long m) {
unsigned long long c = 1;
m = (n - m < m ? n - m : m);
for (long ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
c *= ns;
c /= ms;
}
return c;
};
// ワーシャルフロイド法
void warshallFloyd(int d[100][100], int n) {
for (int k = 0; k < n; ++k)
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (d[i][k] != -1 && d[k][j] != -1) {
if (d[i][j] == -1) {
d[i][j] = d[i][k] + d[k][j];
} else {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
};
// d:隣接行列 n:グラフのサイズ s:始点 dist:始点からの距離が入る配列
void dijkstra(int d[1000][1000], int n, int s, int dist[1000]) {
FOR(i, n) dist[i] = -1;
dist[s] = 0;
priority_queue<PII, vector<PII>, greater<PII>> q;
q.push(PII(0, s));
while (!q.empty()) {
PII p = q.top();
q.pop();
int i = p.second;
if (dist[i] < p.first)
continue;
for (int j = 0; j < n; j++) {
if (d[i][j] == -1)
continue;
if (dist[j] == -1) {
dist[j] = dist[i] + d[i][j];
q.push(PII(dist[j], j));
} else if (dist[j] > dist[i] + d[i][j]) {
dist[j] = dist[i] + d[i][j];
q.push(PII(dist[j], j));
}
}
}
};
// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
// 並行な場合
int m = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3);
if (m == 0)
return false;
// 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
double r = (double)((y4 - y3) * (x3 - x1) - (x4 - x3) * (y3 - y1)) / m;
double s = (double)((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / m;
return (0 < r && r <= 1 && 0 < s && s <= 1);
};
// 外積の計算 AB CD
int crossProdct(int ax, int ay, int bx, int by, int cx, int cy, int dx,
int dy) {
int abx = bx - ax;
int aby = by - ay;
int cdx = cx - dx;
int cdy = cy - dy;
return abx * cdy - cdx - aby;
};
double crossProdct(double ax, double ay, double bx, double by, double cx,
double cy, double dx, double dy) {
double abx = bx - ax;
double aby = by - ay;
double cdx = dx - cx;
double cdy = dy - cy;
return abx * cdy - cdx - aby;
};
// 三角形の内部判定
bool inTriangle(int ax, int ay, int bx, int by, int cx, int cy, int px,
int py) {
int abx = bx - ax;
int aby = by - ay;
int bcx = cx - bx;
int bcy = cy - by;
int cax = ax - cx;
int cay = ay - cy;
int apx = px - ax;
int apy = py - ay;
int bpx = px - bx;
int bpy = py - by;
int cpx = px - cx;
int cpy = py - cy;
int c1 = abx * bpy - aby * bpx;
int c2 = bcx * cpy - bcy * cpx;
int c3 = cax * apy - cay * apx;
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
bool inTriangle(double ax, double ay, double bx, double by, double cx,
double cy, double px, double py) {
double c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
double c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
double c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
void cp(int a1[], int a2[], int l) { FOR(i, l) a2[i] = a1[i]; };
/**
* start
* @author yoshikyoto
*/
int main(int argc, const char *argv[]) {
begin();
double ax, ay, bx, by, cx, cy, px, py;
while (cin >> ax >> ay >> bx >> by >> cx >> cy >> px >> py) {
if (inTriangle(ax, ay, bx, by, cx, cy, px, py)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
#define bit(i) static_cast<bitset<8>>(i)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int>> minpq;
struct edge {
int to, cost;
};
void begin() {
cin.tie(0);
ios::sync_with_stdio(false);
};
int gcd(int a, int b) {
if (a % b == 0) {
return (b);
} else {
return (gcd(b, a % b));
}
};
int lcm(int m, int n) {
if ((0 == m) || (0 == n)) {
return 0;
}
return ((m / gcd(m, n)) * n);
};
unsigned long long comb(long n, long m) {
unsigned long long c = 1;
m = (n - m < m ? n - m : m);
for (long ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
c *= ns;
c /= ms;
}
return c;
};
// ワーシャルフロイド法
void warshallFloyd(int d[100][100], int n) {
for (int k = 0; k < n; ++k)
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (d[i][k] != -1 && d[k][j] != -1) {
if (d[i][j] == -1) {
d[i][j] = d[i][k] + d[k][j];
} else {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
};
// d:隣接行列 n:グラフのサイズ s:始点 dist:始点からの距離が入る配列
void dijkstra(int d[1000][1000], int n, int s, int dist[1000]) {
FOR(i, n) dist[i] = -1;
dist[s] = 0;
priority_queue<PII, vector<PII>, greater<PII>> q;
q.push(PII(0, s));
while (!q.empty()) {
PII p = q.top();
q.pop();
int i = p.second;
if (dist[i] < p.first)
continue;
for (int j = 0; j < n; j++) {
if (d[i][j] == -1)
continue;
if (dist[j] == -1) {
dist[j] = dist[i] + d[i][j];
q.push(PII(dist[j], j));
} else if (dist[j] > dist[i] + d[i][j]) {
dist[j] = dist[i] + d[i][j];
q.push(PII(dist[j], j));
}
}
}
};
// 線分の交差判定
bool isCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
// 並行な場合
int m = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3);
if (m == 0)
return false;
// 媒介変数の値が0より大きく1以下なら交差する、これは問題の状況によって変わるかも。
double r = (double)((y4 - y3) * (x3 - x1) - (x4 - x3) * (y3 - y1)) / m;
double s = (double)((y2 - y1) * (x3 - x1) - (x2 - x1) * (y3 - y1)) / m;
return (0 < r && r <= 1 && 0 < s && s <= 1);
};
// 外積の計算 AB CD
int crossProdct(int ax, int ay, int bx, int by, int cx, int cy, int dx,
int dy) {
int abx = bx - ax;
int aby = by - ay;
int cdx = cx - dx;
int cdy = cy - dy;
return abx * cdy - cdx - aby;
};
double crossProdct(double ax, double ay, double bx, double by, double cx,
double cy, double dx, double dy) {
double abx = bx - ax;
double aby = by - ay;
double cdx = dx - cx;
double cdy = dy - cy;
return abx * cdy - cdx * aby;
};
// 三角形の内部判定
bool inTriangle(int ax, int ay, int bx, int by, int cx, int cy, int px,
int py) {
int abx = bx - ax;
int aby = by - ay;
int bcx = cx - bx;
int bcy = cy - by;
int cax = ax - cx;
int cay = ay - cy;
int apx = px - ax;
int apy = py - ay;
int bpx = px - bx;
int bpy = py - by;
int cpx = px - cx;
int cpy = py - cy;
int c1 = abx * bpy - aby * bpx;
int c2 = bcx * cpy - bcy * cpx;
int c3 = cax * apy - cay * apx;
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
bool inTriangle(double ax, double ay, double bx, double by, double cx,
double cy, double px, double py) {
double c1 = crossProdct(ax, ay, bx, by, bx, by, px, py);
double c2 = crossProdct(bx, by, cx, cy, cx, cy, px, py);
double c3 = crossProdct(cx, cy, ax, ay, ax, ay, px, py);
return (c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0);
};
void cp(int a1[], int a2[], int l) { FOR(i, l) a2[i] = a1[i]; };
/**
* start
* @author yoshikyoto
*/
int main(int argc, const char *argv[]) {
begin();
double ax, ay, bx, by, cx, cy, px, py;
while (cin >> ax >> ay >> bx >> by >> cx >> cy >> px >> py) {
if (inTriangle(ax, ay, bx, by, cx, cy, px, py)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
[["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 33], ["+", 8, 9, 0, 37, 0, 16, 12, 16, 17, 48]]
| 1
| 1,451
|
#include <bits/stdc++.h>
using namespace std;
namespace geometry {
typedef double D;
typedef complex<D> P;
typedef pair<P, P> S;
typedef S L;
typedef pair<P, D> C;
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
bool cmp(const P &a, const P &b) {
if (a.real() != b.real())
return a.real() < b.real();
return a.imag() < b.imag();
}
void debug(P p) { printf("x: %f, y: %f\n", p.real(), p.imag()); }
void debug(C c) {
printf("x: %f, y: %f, r: %f\n", c.first.real(), c.first.imag(), c.second);
}
void debug(S s) {
printf("{\n");
printf(" ");
debug(s.first);
printf(" ");
debug(s.second);
printf("}\n");
}
void debug(vector<P> poly) {
printf("{\n");
for (int i = 0; i < poly.size(); i++) {
printf(" ");
debug(poly[i]);
}
printf("}\n");
}
D norm(P a) { return a.real() * a.real() + a.imag() * a.imag(); }
D dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); }
D cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }
bool isOrthogonal(P a1, P a2, P b1, P b2) {
return EQ(dot(a1 - a2, b1 - b2), 0.0);
}
bool isOrthogonal(L a, L b) {
return isOrthogonal(a.first, a.second, b.first, b.second);
}
bool isParallel(P a1, P a2, P b1, P b2) {
return EQ(cross(a1 - a2, b1 - b2), 0.0);
}
bool isParallel(L a, L b) {
return isParallel(a.first, a.second, b.first, b.second);
}
bool isPointOnLine(P a, P b, P c) { return EQ(cross(b - a, c - a), 0.0); }
bool isPointOnLine(L a, P b) { return isPointOnLine(a.first, a.second, b); }
bool isPointOnSegment(P a, P b, P c) {
return EQ(cross(b - a, c - a), 0.0) && (dot(b - a, c - a) > -EPS) &&
(dot(a - b, c - b) > -EPS);
}
bool isPointOnSegment(S a, P b) { return isPointOnLine(a.first, a.second, b); }
int ccw(P p0, P p1, P p2) {
P a = p1 - p0;
P b = p2 - p0;
if (cross(a, b) > EPS)
return COUNTER_CLOCKWISE;
if (cross(a, b) < -EPS)
return CLOCKWISE;
if (dot(a, b) < -EPS)
return ONLINE_BACK;
if (norm(a) < norm(b))
return ONLINE_FRONT;
return ON_SEGMENT;
}
bool intersect(P p1, P p2, P p3, P p4) {
return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}
bool intersect(S s1, S s2) {
return intersect(s1.first, s1.second, s2.first, s2.second);
}
D distanceLP(P a, P b, P c) { return abs(cross(b - a, c - a)) / abs(b - a); }
D distanceLP(L a, P b) { return distanceLP(a.first, a.second, b); }
D distanceSP(P a, P b, P c) {
if (dot(b - a, c - a) < EPS)
return abs(c - a);
if (dot(a - b, c - b) < EPS)
return abs(c - b);
return abs(cross(b - a, c - a)) / abs(b - a);
}
D distanceSP(S a, P b) { return distanceSP(a.first, a.second, b); }
D distanceCS(C c, S s) { return distanceSP(s, c.first) - c.second; }
bool intersectCL(C c, L l) { return c.second - distanceLP(l, c.first) > -EPS; }
bool intersectCS(C c, S s) {
if (EQ(c.second - abs(c.first - s.first), 0.0) ||
EQ(c.second - abs(c.first - s.second), 0.0))
return true;
if (c.second - distanceSP(s, c.first) > -EPS) {
return (c.second - abs(c.first - s.first) < EPS ||
c.second - abs(c.first - s.second) < EPS);
}
return false;
}
P project(S s, P p) {
P base = s.second - s.first;
D r = dot(p - s.first, base) / norm(base);
return s.first + base * r;
}
P reflect(S s, P p) { return p + (project(s, p) - p) * (D)2.0; }
P crossPoint(S s1, S s2) {
P base = s2.second - s2.first;
D d1 = abs(cross(base, s1.first - s2.first));
D d2 = abs(cross(base, s1.second - s2.first));
D t = d1 / (d1 + d2);
return s1.first + (s1.second - s1.first) * t;
}
D area(vector<P> poly) {
if (poly.size() < 3)
return 0.0;
D res = 0.0;
for (int i = 1; i < poly.size() - 1; i++) {
P v1 = poly[i] - poly[0];
P v2 = poly[i + 1] - poly[0];
res += abs(cross(v1, v2)) / 2;
}
return res;
}
vector<P> convexHull(vector<P> s) {
if (s.size() < 3)
return s;
vector<P> u, l;
sort(s.begin(), s.end(), cmp);
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++) {
for (int n = u.size();
n >= 2 &&
ccw(u[n - 2], u[n - 1], s[i]) !=
CLOCKWISE /* && ccw(u[n - 2], u[n - 1], s[i]) != ONLINE_FRONT*/;
n--) {
u.pop_back();
}
u.push_back(s[i]);
}
for (int i = s.size() - 3; i >= 0; i--) {
for (int n = l.size();
n >= 2 &&
ccw(l[n - 2], l[n - 1], s[i]) !=
CLOCKWISE /* && ccw(l[n - 2], l[n - 1], s[i]) != ONLINE_FRONT*/;
n--) {
l.pop_back();
}
l.push_back(s[i]);
}
reverse(l.begin(), l.end());
for (int i = u.size() - 2; i >= 1; i--) {
l.push_back(u[i]);
}
return l;
}
} // namespace geometry
using namespace geometry;
int main() {
while (true) {
vector<P> poly;
P p;
D x, y;
for (int i = 0; i < 3; i++) {
if (~scanf("%lf %lf", &x, &y))
return 0;
poly.push_back(P(x, y));
}
scanf("%lf %lf", &x, &y);
p = P(x, y);
D a = area(poly);
D b = 0.0;
for (int i = 0; i < 3; i++) {
vector<P> t;
t.push_back(poly[i]);
t.push_back(poly[(i + 1) % 3]);
t.push_back(p);
b += area(t);
}
if (EQ(a, b))
puts("YES");
else
puts("NO");
}
}
|
#include <bits/stdc++.h>
using namespace std;
namespace geometry {
typedef double D;
typedef complex<D> P;
typedef pair<P, P> S;
typedef S L;
typedef pair<P, D> C;
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
bool cmp(const P &a, const P &b) {
if (a.real() != b.real())
return a.real() < b.real();
return a.imag() < b.imag();
}
void debug(P p) { printf("x: %f, y: %f\n", p.real(), p.imag()); }
void debug(C c) {
printf("x: %f, y: %f, r: %f\n", c.first.real(), c.first.imag(), c.second);
}
void debug(S s) {
printf("{\n");
printf(" ");
debug(s.first);
printf(" ");
debug(s.second);
printf("}\n");
}
void debug(vector<P> poly) {
printf("{\n");
for (int i = 0; i < poly.size(); i++) {
printf(" ");
debug(poly[i]);
}
printf("}\n");
}
D norm(P a) { return a.real() * a.real() + a.imag() * a.imag(); }
D dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); }
D cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }
bool isOrthogonal(P a1, P a2, P b1, P b2) {
return EQ(dot(a1 - a2, b1 - b2), 0.0);
}
bool isOrthogonal(L a, L b) {
return isOrthogonal(a.first, a.second, b.first, b.second);
}
bool isParallel(P a1, P a2, P b1, P b2) {
return EQ(cross(a1 - a2, b1 - b2), 0.0);
}
bool isParallel(L a, L b) {
return isParallel(a.first, a.second, b.first, b.second);
}
bool isPointOnLine(P a, P b, P c) { return EQ(cross(b - a, c - a), 0.0); }
bool isPointOnLine(L a, P b) { return isPointOnLine(a.first, a.second, b); }
bool isPointOnSegment(P a, P b, P c) {
return EQ(cross(b - a, c - a), 0.0) && (dot(b - a, c - a) > -EPS) &&
(dot(a - b, c - b) > -EPS);
}
bool isPointOnSegment(S a, P b) { return isPointOnLine(a.first, a.second, b); }
int ccw(P p0, P p1, P p2) {
P a = p1 - p0;
P b = p2 - p0;
if (cross(a, b) > EPS)
return COUNTER_CLOCKWISE;
if (cross(a, b) < -EPS)
return CLOCKWISE;
if (dot(a, b) < -EPS)
return ONLINE_BACK;
if (norm(a) < norm(b))
return ONLINE_FRONT;
return ON_SEGMENT;
}
bool intersect(P p1, P p2, P p3, P p4) {
return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}
bool intersect(S s1, S s2) {
return intersect(s1.first, s1.second, s2.first, s2.second);
}
D distanceLP(P a, P b, P c) { return abs(cross(b - a, c - a)) / abs(b - a); }
D distanceLP(L a, P b) { return distanceLP(a.first, a.second, b); }
D distanceSP(P a, P b, P c) {
if (dot(b - a, c - a) < EPS)
return abs(c - a);
if (dot(a - b, c - b) < EPS)
return abs(c - b);
return abs(cross(b - a, c - a)) / abs(b - a);
}
D distanceSP(S a, P b) { return distanceSP(a.first, a.second, b); }
D distanceCS(C c, S s) { return distanceSP(s, c.first) - c.second; }
bool intersectCL(C c, L l) { return c.second - distanceLP(l, c.first) > -EPS; }
bool intersectCS(C c, S s) {
if (EQ(c.second - abs(c.first - s.first), 0.0) ||
EQ(c.second - abs(c.first - s.second), 0.0))
return true;
if (c.second - distanceSP(s, c.first) > -EPS) {
return (c.second - abs(c.first - s.first) < EPS ||
c.second - abs(c.first - s.second) < EPS);
}
return false;
}
P project(S s, P p) {
P base = s.second - s.first;
D r = dot(p - s.first, base) / norm(base);
return s.first + base * r;
}
P reflect(S s, P p) { return p + (project(s, p) - p) * (D)2.0; }
P crossPoint(S s1, S s2) {
P base = s2.second - s2.first;
D d1 = abs(cross(base, s1.first - s2.first));
D d2 = abs(cross(base, s1.second - s2.first));
D t = d1 / (d1 + d2);
return s1.first + (s1.second - s1.first) * t;
}
D area(vector<P> poly) {
if (poly.size() < 3)
return 0.0;
D res = 0.0;
for (int i = 1; i < poly.size() - 1; i++) {
P v1 = poly[i] - poly[0];
P v2 = poly[i + 1] - poly[0];
res += abs(cross(v1, v2)) / 2;
}
return res;
}
vector<P> convexHull(vector<P> s) {
if (s.size() < 3)
return s;
vector<P> u, l;
sort(s.begin(), s.end(), cmp);
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++) {
for (int n = u.size();
n >= 2 &&
ccw(u[n - 2], u[n - 1], s[i]) !=
CLOCKWISE /* && ccw(u[n - 2], u[n - 1], s[i]) != ONLINE_FRONT*/;
n--) {
u.pop_back();
}
u.push_back(s[i]);
}
for (int i = s.size() - 3; i >= 0; i--) {
for (int n = l.size();
n >= 2 &&
ccw(l[n - 2], l[n - 1], s[i]) !=
CLOCKWISE /* && ccw(l[n - 2], l[n - 1], s[i]) != ONLINE_FRONT*/;
n--) {
l.pop_back();
}
l.push_back(s[i]);
}
reverse(l.begin(), l.end());
for (int i = u.size() - 2; i >= 1; i--) {
l.push_back(u[i]);
}
return l;
}
} // namespace geometry
using namespace geometry;
int main() {
while (true) {
vector<P> poly;
P p;
D x, y;
for (int i = 0; i < 3; i++) {
if (scanf("%lf %lf", &x, &y) == -1)
return 0;
poly.push_back(P(x, y));
}
scanf("%lf %lf", &x, &y);
p = P(x, y);
D a = area(poly);
D b = 0.0;
for (int i = 0; i < 3; i++) {
vector<P> t;
t.push_back(poly[i]);
t.push_back(poly[(i + 1) % 3]);
t.push_back(p);
b += area(t);
}
if (EQ(a, b))
puts("YES");
else
puts("NO");
}
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 91, 17, 92], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 2,006
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
bool flag;
double x1, yt1, x2, y2, x3, y3, xp, yp;
double v[3][2];
double inpr(double v1[2], double v2[2]) {
double ret = v1[0] * v2[0] + v1[1] * v2[1];
return ret;
}
int main() {
x2 = -123456;
cin >> x1 >> yt1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
while (x2 != -123456) {
flag = true;
v[0][0] = -(y2 - yt1);
v[0][1] = x2 - x1;
v[1][0] = x3 - x1;
v[1][1] = y3 - yt1;
v[2][0] = xp - x1;
v[2][1] = yp - yt1;
if (inpr(v[0], v[1]) * inpr(v[0], v[2]) < 0)
flag = false;
v[0][0] = -(y3 - y2);
v[0][1] = x3 - x2;
v[1][0] = x1 - x2;
v[1][1] = yt1 - y2;
v[2][0] = xp - x2;
v[2][1] = yp - y2;
if (inpr(v[0], v[1]) * inpr(v[0], v[2]) < 0)
flag = false;
v[0][0] = -(yt1 - y3);
v[0][1] = x1 - x3;
v[1][0] = x2 - x3;
v[1][1] = y2 - y3;
v[2][0] = xp - x3;
v[2][1] = yp - y3;
if (inpr(v[0], v[1]) * inpr(v[0], v[2]) < 0)
flag = false;
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
x2 = -123456;
cin >> x1 >> yt1 >> x2 >> y2 >> x3 >> y3;
}
return 0;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@ @*/
/*@ debug output erased ? @*/
/*@ @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
bool flag;
double x1, yt1, x2, y2, x3, y3, xp, yp;
double v[3][2];
double inpr(double v1[2], double v2[2]) {
double ret = v1[0] * v2[0] + v1[1] * v2[1];
return ret;
}
int main() {
x2 = -123456;
cin >> x1 >> yt1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
while (x2 != -123456) {
flag = true;
v[0][0] = -(y2 - yt1);
v[0][1] = x2 - x1;
v[1][0] = x3 - x1;
v[1][1] = y3 - yt1;
v[2][0] = xp - x1;
v[2][1] = yp - yt1;
if (inpr(v[0], v[1]) * inpr(v[0], v[2]) < 0)
flag = false;
v[0][0] = -(y3 - y2);
v[0][1] = x3 - x2;
v[1][0] = x1 - x2;
v[1][1] = yt1 - y2;
v[2][0] = xp - x2;
v[2][1] = yp - y2;
if (inpr(v[0], v[1]) * inpr(v[0], v[2]) < 0)
flag = false;
v[0][0] = -(yt1 - y3);
v[0][1] = x1 - x3;
v[1][0] = x2 - x3;
v[1][1] = y2 - y3;
v[2][0] = xp - x3;
v[2][1] = yp - y3;
if (inpr(v[0], v[1]) * inpr(v[0], v[2]) < 0)
flag = false;
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
x2 = -123456;
cin >> x1 >> yt1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
}
return 0;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@ @*/
/*@ debug output erased ? @*/
/*@ @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
|
[["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 514
|
#include <bits/stdc++.h>
using namespace std;
class D3 {
public:
double x;
double y;
double z;
//?????????????????????
D3(double x_ = 0.0, double y_ = 0.0, double z_ = 0.0) {
x = x_;
y = y_;
z = z_;
}
//??????
D3 Cross_product(D3 partner) {
D3 ret(y * partner.z - z * partner.y, z * partner.x - x * partner.z,
x * partner.y - y * partner.x);
return ret;
}
//??????
double Inner_product(D3 partner) {
return x * partner.x + y * partner.y + z * partner.z;
}
//?????????????????????????????????
D3 Make_vector(D3 partner) {
D3 ret(partner.x - x, partner.y - y, partner.z - z);
return ret;
}
//???????§????2????????????????????¢???????±???????
double S_vec(D3 A, D3 B) {
D3 G;
G = A.Cross_product(B);
return sqrt(G.Inner_product(G)) / 2;
}
//??????????????¢???????±???????
double S_point(D3 A, D3 B, D3 C) {
return S_vec(A.Make_vector(B), A.Make_vector(C));
}
//???????§????3????????????????????????????±???????
double V_vec(D3 A, D3 B, D3 C) {
D3 G;
G = A.Cross_product(B);
return G.Inner_product(C) / 6;
}
// 4???????????????????±???????
double V_point(D3 A, D3 B, D3 C, D3 D) {
return V_vec(A.Make_vector(B), A.Make_vector(C), A.Make_vector(D));
}
D3 operator+(D3 partner) {
return D3(x + partner.x, y + partner.y, z + partner.z);
}
D3 operator-(D3 partner) {
return D3(x - partner.x, y - partner.y, z - partner.z);
}
D3 operator*(D3 partner) {
return D3(x * partner.x, y * partner.y, z * partner.z);
}
D3 operator/(D3 partner) {
return D3(x / partner.x, y / partner.y, z / partner.z);
}
D3 operator*(double d) { return D3(x * d, y * d, z * d); }
D3 operator/(double d) { return D3(x / d, y / d, z / d); }
bool operator==(D3 partner) {
return x == partner.x && y == partner.y && z == partner.z;
}
double length() { return sqrt(x * x + y * y + z * z); }
//???????????????????????????
//????????¨???
D3 Unit_vec() { return D3(*this) / (*this).length(); }
//????????????????????????
D3 Inverse_vec() { return D3(*this) * -1; }
//?????´????????????
bool Vertical(D3 partner) { return (*this).Inner_product(partner) == 0; }
//??????????????????
bool Parallel(D3 partner) {
return (*this).Unit_vec() == partner.Unit_vec() ||
(*this).Unit_vec().Inverse_vec() == partner.Unit_vec();
}
};
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
D3 X(x1, y1), Y(x2, y2), Z(x3, y3), P(xp, yp), calc;
if (calc.S_point(X, Y, Z) - (calc.S_point(X, Y, P) + calc.S_point(X, Z, P) +
calc.S_point(Z, Y, P)) <
1e-9) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
class D3 {
public:
double x;
double y;
double z;
//?????????????????????
D3(double x_ = 0.0, double y_ = 0.0, double z_ = 0.0) {
x = x_;
y = y_;
z = z_;
}
//??????
D3 Cross_product(D3 partner) {
D3 ret(y * partner.z - z * partner.y, z * partner.x - x * partner.z,
x * partner.y - y * partner.x);
return ret;
}
//??????
double Inner_product(D3 partner) {
return x * partner.x + y * partner.y + z * partner.z;
}
//?????????????????????????????????
D3 Make_vector(D3 partner) {
D3 ret(partner.x - x, partner.y - y, partner.z - z);
return ret;
}
//???????§????2????????????????????¢???????±???????
double S_vec(D3 A, D3 B) {
D3 G;
G = A.Cross_product(B);
return sqrt(G.Inner_product(G)) / 2;
}
//??????????????¢???????±???????
double S_point(D3 A, D3 B, D3 C) {
return S_vec(A.Make_vector(B), A.Make_vector(C));
}
//???????§????3????????????????????????????±???????
double V_vec(D3 A, D3 B, D3 C) {
D3 G;
G = A.Cross_product(B);
return G.Inner_product(C) / 6;
}
// 4???????????????????±???????
double V_point(D3 A, D3 B, D3 C, D3 D) {
return V_vec(A.Make_vector(B), A.Make_vector(C), A.Make_vector(D));
}
D3 operator+(D3 partner) {
return D3(x + partner.x, y + partner.y, z + partner.z);
}
D3 operator-(D3 partner) {
return D3(x - partner.x, y - partner.y, z - partner.z);
}
D3 operator*(D3 partner) {
return D3(x * partner.x, y * partner.y, z * partner.z);
}
D3 operator/(D3 partner) {
return D3(x / partner.x, y / partner.y, z / partner.z);
}
D3 operator*(double d) { return D3(x * d, y * d, z * d); }
D3 operator/(double d) { return D3(x / d, y / d, z / d); }
bool operator==(D3 partner) {
return x == partner.x && y == partner.y && z == partner.z;
}
double length() { return sqrt(x * x + y * y + z * z); }
//???????????????????????????
//????????¨???
D3 Unit_vec() { return D3(*this) / (*this).length(); }
//????????????????????????
D3 Inverse_vec() { return D3(*this) * -1; }
//?????´????????????
bool Vertical(D3 partner) { return (*this).Inner_product(partner) == 0; }
//??????????????????
bool Parallel(D3 partner) {
return (*this).Unit_vec() == partner.Unit_vec() ||
(*this).Unit_vec().Inverse_vec() == partner.Unit_vec();
}
};
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
D3 X(x1, y1), Y(x2, y2), Z(x3, y3), P(xp, yp), calc;
if (abs(calc.S_point(X, Y, Z) -
(calc.S_point(X, Y, P) + calc.S_point(X, Z, P) +
calc.S_point(Z, Y, P))) < 1e-6) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 795
|
//#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
using namespace std;
int main() {
double x[4], y[4], dx[3], dy[3], dpx[3], dpy[3];
double th[3], pth[3];
int check = 0;
bool ans = true;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
if (x[1] == 0 && y[1] == 0) {
swap(x[0], x[1]);
swap(y[0], y[1]);
}
if (x[2] == 0 && y[2] == 0) {
swap(x[0], x[2]);
swap(y[0], y[2]);
}
if (sin(atan2(y[1] - y[0], x[1] - x[0]) - atan2(y[2] - y[0], x[2] - x[0])) >
0) {
swap(x[1], x[2]);
swap(y[1], y[2]);
}
for (int i = 0; i < 3; i++) {
dx[i] = x[(i + 1) % 3] - x[i];
dy[i] = y[(i + 1) % 3] - y[i];
dpx[i] = x[3] - x[i];
dpy[i] = y[3] - y[i];
th[i] = atan2(dy[i], dx[i]);
pth[i] = atan2(dpy[i], dpx[i]);
}
for (int i = 0; i < 3; i++) {
if (sin(th[i] - pth[i]) > 0) {
ans = false;
break;
}
}
cout << (ans ? "YES" : "NO") << endl;
}
}
|
//#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>
using namespace std;
int main() {
double x[4], y[4], dx[3], dy[3], dpx[3], dpy[3];
double th[3], pth[3];
int check = 0;
bool ans = true;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
ans = true;
if (x[1] == 0 && y[1] == 0) {
swap(x[0], x[1]);
swap(y[0], y[1]);
}
if (x[2] == 0 && y[2] == 0) {
swap(x[0], x[2]);
swap(y[0], y[2]);
}
if (sin(atan2(y[1] - y[0], x[1] - x[0]) - atan2(y[2] - y[0], x[2] - x[0])) >
0) {
swap(x[1], x[2]);
swap(y[1], y[2]);
}
for (int i = 0; i < 3; i++) {
dx[i] = x[(i + 1) % 3] - x[i];
dy[i] = y[(i + 1) % 3] - y[i];
dpx[i] = x[3] - x[i];
dpy[i] = y[3] - y[i];
th[i] = atan2(dy[i], dx[i]);
pth[i] = atan2(dpy[i], dpx[i]);
}
for (int i = 0; i < 3; i++) {
if (sin(th[i] - pth[i]) > 0) {
ans = false;
break;
}
}
cout << (ans ? "YES" : "NO") << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 146], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 473
|
#include <math.h>
#include <stdio.h>
double eps = 1e-10;
int main() {
double x1, x2, x3, y1, y2, y3, xp, yp;
double s, s1, s2, s3;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
//?????§????¢??????¢???
s = ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2;
s1 = ((xp - x1) * (y2 - y1) - (yp - y1) * (x2 - x1)) / 2;
s2 = ((xp - x1) * (y3 - y1) - (yp - y1) * (x3 - x1)) / 2;
s3 = ((xp - x2) * (y3 - y2) - (yp - y2) * (x3 - x2)) / 2;
s = fabs(s);
s1 = fabs(s1);
s2 = fabs(s2);
s3 = fabs(s3);
if (s - (s1 + s2 + s3) <= eps)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
double eps = 1e-10;
int main() {
double x1, x2, x3, y1, y2, y3, xp, yp;
double s, s1, s2, s3;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
//?????§????¢??????¢???
s = ((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1)) / 2;
s1 = ((xp - x1) * (y2 - y1) - (yp - y1) * (x2 - x1)) / 2;
s2 = ((xp - x1) * (y3 - y1) - (yp - y1) * (x3 - x1)) / 2;
s3 = ((xp - x2) * (y3 - y2) - (yp - y2) * (x3 - x2)) / 2;
s = fabs(s);
s1 = fabs(s1);
s2 = fabs(s2);
s3 = fabs(s3);
if (fabs(s - (s1 + s2 + s3)) <= eps)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
| 1
| 261
|
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a), end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;
double dist(double x1, double y1, double x2, double y2) {
return sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
}
double triangleArea(double x, double y, double z) {
return (y * z * sin(acos((y * y + z * z - x * x) / (2 * y * z)))) / 2;
}
double inputXY(double x1, double y1, double x2, double y2, double x3,
double y3) {
double x, y, z;
x = dist(x1, y1, x2, y2);
y = dist(x2, y2, x3, y3);
z = dist(x3, y3, x1, y1);
return triangleArea(x, y, z);
}
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
double allArea, area12, area23, area31;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
allArea = inputXY(x1, y1, x2, y2, x3, y3);
area12 = inputXY(xp, yp, x2, y2, x1, y1);
area23 = inputXY(x2, y2, x3, y3, xp, yp);
area31 = inputXY(x3, y3, x1, y1, xp, yp);
if (abs(allArea - (area12 + area23 + area31)) < 0.000000000000001)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a), end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;
double dist(double x1, double y1, double x2, double y2) {
return sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
}
double triangleArea(double x, double y, double z) {
return (y * z * sin(acos((y * y + z * z - x * x) / (2 * y * z)))) / 2;
}
double inputXY(double x1, double y1, double x2, double y2, double x3,
double y3) {
double x, y, z;
x = dist(x1, y1, x2, y2);
y = dist(x2, y2, x3, y3);
z = dist(x3, y3, x1, y1);
return triangleArea(x, y, z);
}
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
double allArea, area12, area23, area31;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
allArea = inputXY(x1, y1, x2, y2, x3, y3);
area12 = inputXY(xp, yp, x2, y2, x1, y1);
area23 = inputXY(x2, y2, x3, y3, xp, yp);
area31 = inputXY(x3, y3, x1, y1, xp, yp);
if (abs(allArea - (area12 + area23 + area31)) < 0.000001)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 377
|
#include <bits/stdc++.h>
using namespace std;
typedef struct {
double x, y;
} vec_t;
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
vec_t AB, BC, CA, AP, BP, CP;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
AB.x = x2 - x1, AB.y = y2 - y1;
BC.x = x3 - x2, BC.y = y3 - y2;
CA.x = x1 - x3, CA.y = y1 - y3;
AP.x = xp - x1, AP.y = yp - y1;
BP.x = xp - x2, BP.y = yp - y2;
CP.x = xp - x3, CP.y = yp - y3;
double c1 = AB.x * BP.y - AB.y * BP.x;
double c2 = BC.x * CP.y - BC.y * CP.x;
double c3 = CA.x * AP.y - CA.y * AP.x;
if ((c1 < 0 && c2 < 0 && c3 < 0) || (c1 > 0 && c2 > 0 && c3 > 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef struct {
double x, y;
} vec_t;
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
vec_t AB, BC, CA, AP, BP, CP;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
AB.x = x2 - x1, AB.y = y2 - y1;
BC.x = x3 - x2, BC.y = y3 - y2;
CA.x = x1 - x3, CA.y = y1 - y3;
AP.x = xp - x1, AP.y = yp - y1;
BP.x = xp - x2, BP.y = yp - y2;
CP.x = xp - x3, CP.y = yp - y3;
double c1 = AB.x * BP.y - AB.y * BP.x;
double c2 = BC.x * CP.y - BC.y * CP.x;
double c3 = CA.x * AP.y - CA.y * AP.x;
if ((c1 < 0 && c2 < 0 && c3 < 0) || (c1 > 0 && c2 > 0 && c3 > 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 274
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
ios::sync_with_stdio(false);
vd x(3), y(3);
double px, py;
double a1, a2, a3;
bool s = false;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> px >> py) {
a1 = (x[1] - x[0]) * (py - y[1]) - (y[1] - y[0]) * (px - x[1]);
a2 = (x[2] - x[1]) * (py - y[2]) - (y[2] - y[1]) * (px - x[2]);
a3 = (x[0] - x[2]) * (py - y[0]) - (y[0] - y[2]) * (px - x[0]);
if (((a1 > 0) && (a2 > 0) && (a3 > 0)) ||
((a1 < 0) && (a2 < 0) && (a3 < 0)))
s = !s;
if (s)
puts("YES");
else
puts("NO");
}
}
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int main() {
ios::sync_with_stdio(false);
vd x(3), y(3);
double px, py;
double a1, a2, a3;
bool s = false;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> px >> py) {
s = false;
a1 = (x[1] - x[0]) * (py - y[1]) - (y[1] - y[0]) * (px - x[1]);
a2 = (x[2] - x[1]) * (py - y[2]) - (y[2] - y[1]) * (px - x[2]);
a3 = (x[0] - x[2]) * (py - y[0]) - (y[0] - y[2]) * (px - x[0]);
if (((a1 > 0) && (a2 > 0) && (a3 > 0)) ||
((a1 < 0) && (a2 < 0) && (a3 < 0)))
s = !s;
if (s)
puts("YES");
else
puts("NO");
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 147], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 464
|
#include <iostream>
using namespace std;
int main(void) {
double x[3] = {0, 0, 0};
double y[3] = {0, 0, 0};
double xp = 0, yp = 0;
int flag[3] = {0, 0, 0};
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
for (int i = 0; i < 3; i++) {
int temp1 = (i + 1) % 3;
int temp2 = (i + 2) % 3;
double checkI = (y[temp1] - y[i]) * (x[temp2] - x[i]) +
(x[temp1] - x[i]) * (y[temp2] - y[i]);
double checkP =
(y[temp1] - y[i]) * (xp - x[i]) + (x[temp1] - x[i]) * (yp - y[i]);
if (checkI * checkP > 0) {
flag[i] = 1;
}
}
if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
flag[0] = 0;
flag[1] = 0;
flag[2] = 0;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(void) {
double x[3] = {0, 0, 0};
double y[3] = {0, 0, 0};
double xp = 0, yp = 0;
int flag[3] = {0, 0, 0};
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
for (int i = 0; i < 3; i++) {
int temp1 = (i + 1) % 3;
int temp2 = (i + 2) % 3;
double checkI = (y[temp1] - y[i]) * (x[temp2] - x[i]) -
(x[temp1] - x[i]) * (y[temp2] - y[i]);
double checkP =
(y[temp1] - y[i]) * (xp - x[i]) - (x[temp1] - x[i]) * (yp - y[i]);
if (checkI * checkP > 0) {
flag[i] = 1;
}
}
if (flag[0] == 1 && flag[1] == 1 && flag[2] == 1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
flag[0] = 0;
flag[1] = 0;
flag[2] = 0;
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33]]
| 1
| 323
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef complex<double> P;
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a);
push_back(b);
} // line
};
struct C {
P c;
double r;
C(const P &c, double r) : c(c), r(r) {} // circle
};
/*complex ?????????*/
namespace std {
bool operator<(const P &a, const P &b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
// return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
}
bool operator==(const P &a, const P &b) {
return a.real() == b.real() && a.imag() == b.imag();
}
} // namespace std
/*????¨?????????????????¨???????????????????*/
int ccw(P a, P b, P c) {
b -= a;
c -= a;
if (cross(b, c) > 0)
return +1; // counter clockwise
if (cross(b, c) < 0)
return -1; // clockwise
if (dot(b, c) < 0)
return +2; // c--a--b on line
if (norm(b) < norm(c))
return -2; // a--b--c on line
return 0;
}
int main() {
vector<P> v(4);
vector<pdd> p(3);
vector<double> t(3, 0);
pdd temp;
while (cin >> p[0].first >> p[0].second >> p[1].first >> p[1].second >>
p[2].first >> p[2].second >> temp.first >> temp.second) {
rep(i, 3) v[i] = P(p[i].first, p[i].second);
P pit = P(temp.first, temp.second);
v[3] = v[0];
bool flag = true;
P hoge;
rep(i, 3) t[i] = cross((-v[i] + v[i + 1]), -v[i + 1] + pit);
if ((t[0] > 0 && t[1] > 0 && t[2]) || (t[0] < 0 && t[1] < 0 && t[2]))
puts("YES");
else
puts("NO");
}
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define vi vector<int>
#define vvi vector<vector<int>>
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i, n) for (int i = 0; i < n; i++)
#define loop(i, s, n) for (int i = s; i < n; i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef complex<double> P;
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a);
push_back(b);
} // line
};
struct C {
P c;
double r;
C(const P &c, double r) : c(c), r(r) {} // circle
};
/*complex ?????????*/
namespace std {
bool operator<(const P &a, const P &b) {
return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
// return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
}
bool operator==(const P &a, const P &b) {
return a.real() == b.real() && a.imag() == b.imag();
}
} // namespace std
/*????¨?????????????????¨???????????????????*/
int ccw(P a, P b, P c) {
b -= a;
c -= a;
if (cross(b, c) > 0)
return +1; // counter clockwise
if (cross(b, c) < 0)
return -1; // clockwise
if (dot(b, c) < 0)
return +2; // c--a--b on line
if (norm(b) < norm(c))
return -2; // a--b--c on line
return 0;
}
int main() {
vector<P> v(4);
vector<pdd> p(3);
vector<double> t(3, 0);
pdd temp;
while (cin >> p[0].first >> p[0].second >> p[1].first >> p[1].second >>
p[2].first >> p[2].second >> temp.first >> temp.second) {
rep(i, 3) v[i] = P(p[i].first, p[i].second);
P pit = P(temp.first, temp.second);
v[3] = v[0];
bool flag = true;
P hoge;
rep(i, 3) t[i] = cross((-v[i] + v[i + 1]), -v[i + 1] + pit);
if ((t[0] > 0 && t[1] > 0 && t[2] > 0) ||
(t[0] < 0 && t[1] < 0 && t[2] < 0))
puts("YES");
else
puts("NO");
}
}
|
[["+", 51, 16, 31, 23, 0, 16, 12, 16, 17, 47], ["+", 51, 16, 31, 23, 0, 16, 12, 16, 12, 13], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 17, 18], ["+", 51, 16, 12, 23, 0, 16, 12, 16, 12, 13]]
| 1
| 670
|
#include <iostream>
using namespace std;
struct TCoordinate {
double x;
double y;
};
double GetCrossProduct(const TCoordinate &V1, const TCoordinate &V2) {
return V1.x * V2.y - V1.y * V2.x;
}
bool IsSameSide(const TCoordinate &T1, const TCoordinate &T2,
const TCoordinate &L1, const TCoordinate &L2) {
TCoordinate VectorL1T1 = {T1.x - L1.x, T1.y - L1.y};
TCoordinate VectorL1T2 = {T2.x - L1.x, T2.y - L1.y};
TCoordinate VectorL1L2 = {L2.x - L1.x, L2.y - L1.y};
double CrossProductT1 = GetCrossProduct(VectorL1T1, VectorL1L2);
double CrossProductT2 = GetCrossProduct(VectorL1T1, VectorL1L2);
if (CrossProductT1 * CrossProductT2 > 0) {
return true;
} else {
return false;
}
}
int main() {
while (true) {
TCoordinate A1, A2, A3, Ap;
cin >> A1.x >> A1.y >> A2.x >> A2.y >> A3.x >> A3.y >> Ap.x >> Ap.y;
if (cin.eof() == true)
break;
if (IsSameSide(A3, Ap, A1, A2) && IsSameSide(A1, Ap, A2, A3) &&
IsSameSide(A2, Ap, A3, A1)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
struct TCoordinate {
double x;
double y;
};
double GetCrossProduct(const TCoordinate &V1, const TCoordinate &V2) {
return V1.x * V2.y - V1.y * V2.x;
}
bool IsSameSide(const TCoordinate &T1, const TCoordinate &T2,
const TCoordinate &L1, const TCoordinate &L2) {
TCoordinate VectorL1T1 = {T1.x - L1.x, T1.y - L1.y};
TCoordinate VectorL1T2 = {T2.x - L1.x, T2.y - L1.y};
TCoordinate VectorL1L2 = {L2.x - L1.x, L2.y - L1.y};
double CrossProductT1 = GetCrossProduct(VectorL1T1, VectorL1L2);
double CrossProductT2 = GetCrossProduct(VectorL1T2, VectorL1L2);
if (CrossProductT1 * CrossProductT2 > 0) {
return true;
} else {
return false;
}
}
int main() {
while (true) {
TCoordinate A1, A2, A3, Ap;
cin >> A1.x >> A1.y >> A2.x >> A2.y >> A3.x >> A3.y >> Ap.x >> Ap.y;
if (cin.eof() == true)
break;
if (IsSameSide(A3, Ap, A1, A2) && IsSameSide(A1, Ap, A2, A3) &&
IsSameSide(A2, Ap, A3, A1)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22]]
| 1
| 302
|
#include <cassert>
#include <iostream>
int f(int x) { return x * x; }
int main() {
while (true) {
int d;
std::cin >> d;
if (std::cin.eof())
break;
int s = 0;
for (int x = d; x < 600; x += d) {
s += d * f(x);
}
std::cout << s;
}
return 0;
}
|
#include <cassert>
#include <iostream>
int f(int x) { return x * x; }
int main() {
while (true) {
int d;
std::cin >> d;
if (std::cin.eof())
break;
int s = 0;
for (int x = d; x < 600; x += d) {
s += d * f(x);
}
std::cout << s << std::endl;
;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 345, 348], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 0, 349], ["+", 8, 9, 0, 1, 0, 16, 12, 343, 141, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 90
|
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define MAX 256
#define S(x) (x * x)
int f(int z) {
if (z < 10)
return 1;
return 1 + f(z / 10);
}
int main(void) {
int ans[MAX];
for (int i = 0; i < MAX; i++) {
ans[i] = 0;
}
int d;
int i = 0;
while (scanf("%d", &d) != EOF) {
for (int j = d; j <= 600 - d; j += d) {
ans[i] += S(d) * d;
}
i++;
}
for (int j = 0; j < i; j++) {
printf("%d\n", ans[j]);
}
return 0;
}
|
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
#define MAX 256
#define S(x) (x * x)
int f(int z) {
if (z < 10)
return 1;
return 1 + f(z / 10);
}
int main(void) {
int ans[MAX];
for (int i = 0; i < MAX; i++) {
ans[i] = 0;
}
int d;
int i = 0;
while (scanf("%d", &d) != EOF) {
for (int j = d; j <= 600 - d; j += d) {
ans[i] += S(j) * d;
}
i++;
}
for (int j = 0; j < i; j++) {
printf("%d\n", ans[j]);
}
return 0;
}
|
[["-", 0, 11, 12, 16, 31, 2, 3, 4, 0, 22], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 22]]
| 1
| 174
|
#include <iostream>
using namespace std;
int main() {
int N;
while (cin >> N) {
int count = 0;
for (int i = 0; i < 600 / N - 1; i++) {
count += N * (N + i * N) * (N + i * N);
}
cout << count;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N;
while (cin >> N) {
int count = 0;
for (int i = 0; i < 600 / N - 1; i++) {
count += N * (N + i * N) * (N + i * N);
}
cout << count << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 75
|
#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
int n, res;
double buf;
while (cin >> n) {
res = 0;
for (int i = 0; i <= 600 - n; i += n) {
res += pow(i, 2) * n;
}
cout << res;
}
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
int n, res;
double buf;
while (cin >> n) {
res = 0;
for (int i = 0; i <= 600 - n; i += n) {
res += pow(i, 2) * n;
}
cout << res << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 72
|
#include <stdio.h>
int main() {
int n, ans, i;
while (scanf("%d", &n) != EOF) {
ans = 0;
for (i = 1; i * n < 600; i++)
ans += (i * n) * (i * n);
printf("%d\n", ans * (60 / i));
}
}
|
#include <stdio.h>
int main() {
int n, ans, i;
while (scanf("%d", &n) != EOF) {
ans = 0;
for (i = 1; i * n < 600; i++)
ans += (i * n) * (i * n);
printf("%d\n", ans * (600 / i));
}
}
|
[["-", 3, 4, 0, 16, 12, 23, 0, 16, 31, 13], ["+", 3, 4, 0, 16, 12, 23, 0, 16, 31, 13]]
| 1
| 80
|
#include <cstdio>
#include <iostream>
#define N 600
double f(double x) { return x * x; }
int main(void) {
int d, i;
double sum;
while (std::cin >> d) {
sum = 0;
for (int i = d; i < N; i += d) {
sum += f(i) * d;
}
std::cout << sum << std::endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#define N 600
int f(int x) { return x * x; }
int main(void) {
int d, i;
int sum;
while (std::cin >> d) {
sum = 0;
for (int i = d; i < N; i += d) {
sum += f(i) * d;
}
std::cout << sum << std::endl;
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
| 1
| 88
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
double area = 0;
for (int i = d; i <= 600 - d; i += d) {
area += i * i * d;
}
cout << area << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int area = 0;
for (int i = d; i <= 600 - d; i += d) {
area += i * i * d;
}
cout << area << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40]]
| 1
| 64
|
#include <iostream>
using namespace std;
int main(void) {
int d, s;
while (1) {
cin >> d;
if (cin.eof())
break;
s = 0;
for (int x = d; x < 600; x += d)
s += d * x * x;
cout << s;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(void) {
int d, s;
while (1) {
cin >> d;
if (cin.eof())
break;
s = 0;
for (int x = d; x < 600; x += d)
s += d * x * x;
cout << s << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 72
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <stack>
#include <vector>
#define EPS 1e-6
using namespace std;
typedef complex<double> coor;
double cross(coor a, coor b) {
return a.real() * b.imag() - a.imag() * b.real();
}
double dot(coor a, coor b) { return a.real() * b.real() + a.imag() * b.imag(); }
int main() {
int n;
while (scanf(" %d ", &n) == 1) {
int sum = 0;
for (int i = n; i <= 600; i += n) {
sum += i * i * n;
}
printf("%d\n", sum);
}
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <stack>
#include <vector>
#define EPS 1e-6
using namespace std;
typedef complex<double> coor;
double cross(coor a, coor b) {
return a.real() * b.imag() - a.imag() * b.real();
}
double dot(coor a, coor b) { return a.real() * b.real() + a.imag() * b.imag(); }
int main() {
int n;
while (scanf(" %d ", &n) == 1) {
int sum = 0;
for (int i = n; i < 600; i += n) {
sum += i * i * n;
}
printf("%d\n", sum);
}
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
| 1
| 165
|
#include <iostream>
using namespace std;
unsigned long long f(unsigned long long x) { return x * x; }
int main() {
int d;
while (cin >> d) {
unsigned long long s;
for (int i = d; i <= 600 - d; i += d)
s += d * f(i);
cout << s << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
unsigned long long f(unsigned long long x) { return x * x; }
int main() {
int d;
while (cin >> d) {
unsigned long long s = 0;
for (int i = d; i <= 600 - d; i += d)
s += d * f(i);
cout << s << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
| 1
| 80
|
#include <iostream>
using namespace std;
int main() {
int d;
cin >> d;
int sum = 0;
for (int i = 0; i < 600; i += d) {
sum = sum + i * i * d;
}
cout << sum << endl;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int sum = 0;
for (int i = 0; i < 600; i += d) {
sum = sum + i * i * d;
}
cout << sum << endl;
}
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 57
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int y = 0;
for (int i = 1; i <= 600; i++) {
y += d * (d * i) * (d * i);
}
cout << y << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int y = 0;
for (int i = 1; i * d < 600; i++) {
y += d * (d * i) * (d * i);
}
cout << y << endl;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
| 1
| 69
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int s;
s = 600 / d;
int a;
a = 0;
int b;
b = 0;
while (a < s) {
b = b + d * d * a * a;
a = a + 1;
}
cout << a * d << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int s;
s = 600 / d;
int a;
a = 0;
int b;
b = 0;
while (a < s) {
b = b + d * d * a * a;
a = a + 1;
}
cout << b * d << endl;
}
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22]]
| 1
| 80
|
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
ll in;
while (cin >> in) {
ll sum = 0;
for (ll i = in; i <= 600; i += in) {
sum += (i * in);
}
cout << sum << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
ll in;
while (cin >> in) {
ll sum = 0;
for (ll i = in; i < 600; i += in) {
sum += (i * i * in);
}
cout << sum << endl;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 11, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 11, 12, 23, 0, 16, 31, 16, 17, 48]]
| 1
| 68
|
#include <iostream>
using namespace std;
int main() {
int d;
long sum;
int n;
while (cin >> d) {
sum = 0;
n = 600 / d;
for (int i = 1; i <= n; i++) {
sum += d * d * d * i * i;
}
cout << sum << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
long sum;
int n;
while (cin >> d) {
sum = 0;
n = 600 / d;
for (int i = 1; i < n; i++) {
sum += d * d * d * i * i;
}
cout << sum << endl;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
| 1
| 76
|
#include <iostream>
using namespace std;
int main() {
int d;
cin >> d;
int integral = 0;
for (int i = 0; i < 600 / d; i++) {
int x = i * d;
int y = x * x;
integral += y * d;
}
cout << integral << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int integral = 0;
for (int i = 0; i < 600 / d; i++) {
int x = i * d;
int y = x * x;
integral += y * d;
}
cout << integral << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 71
|
#include <iostream>
using namespace std;
int main(void) {
int d;
while (cin >> d) {
int sum = 0;
for (int i = 0; i < 600; i += d) {
sum += d * i * i;
}
cout << sum;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(void) {
int d;
while (cin >> d) {
int sum = 0;
for (int i = 0; i < 600; i += d) {
sum += d * i * i;
}
cout << sum << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 61
|
while data = gets
d = data.to_i
s = 0
loop_num = 1
while loop_num * d >= 600
s += ((loop_num * d)**2) * d
loop_num += 1
end
puts s
end
|
while data = gets
d = data.to_i
s = 0
loop_num = 1
until loop_num * d >= 600
s += ((loop_num * d)**2) * d
loop_num += 1
end
puts s
end
|
[["-", 0, 493, 0, 89, 8, 170, 0, 89, 0, 89], ["+", 0, 493, 0, 89, 8, 170, 0, 750, 0, 750]]
| 4
| 41
|
while line = gets
width = line.to_i
sum = 0
(600 / width).times do |i|
x = i * d
sum += x**2 * d
end
puts sum
end
|
while line = gets
width = line.to_i
sum = 0
(600 / width).times do |i|
x = i * width
sum += x**2 * width
end
puts sum
end
|
[["-", 196, 737, 8, 736, 0, 662, 12, 738, 12, 22], ["+", 196, 737, 8, 736, 0, 662, 12, 738, 12, 22], ["-", 196, 737, 8, 736, 0, 755, 12, 738, 12, 22], ["+", 196, 737, 8, 736, 0, 755, 12, 738, 12, 22]]
| 4
| 39
|
#include <iostream>
using namespace std;
bool judge(double x1, double x2, double x3, double y1, double y2, double y3,
double xp, double yp) {
if (((x2 - x1) * (yp - y2)) - ((y2 - y1) * (xp - x2)) > 0) {
if (((x3 - x2) * (yp - y3)) - ((y3 - y2) * (xp - x3)) > 0) {
if (((x1 - x3) * (yp - y1)) - ((y1 - y3) * (xp - x1)) > 0) {
return true;
}
}
}
if (((x2 - x1) * (yp - y2)) - ((y2 - y1) * (xp - x2)) < 0) {
if (((x3 - x2) * (yp - y3)) - ((y3 - y2) * (xp - x3)) < 0) {
if (((x1 - x3) * (yp - y1)) - ((y1 - y3) * (xp - x1)) < 0) {
return true;
}
}
}
return false;
}
int main(void) {
double x1, x2, x3, y1, y2, y3;
double xp, yp;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
bool d;
d = judge(x1, x2, x3, y1, y2, y3, xp, yp);
if (d) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
bool judge(double x1, double x2, double x3, double y1, double y2, double y3,
double xp, double yp) {
if (((x2 - x1) * (yp - y2)) - ((y2 - y1) * (xp - x2)) > 0) {
if (((x3 - x2) * (yp - y3)) - ((y3 - y2) * (xp - x3)) > 0) {
if (((x1 - x3) * (yp - y1)) - ((y1 - y3) * (xp - x1)) > 0) {
return true;
}
}
}
if (((x2 - x1) * (yp - y2)) - ((y2 - y1) * (xp - x2)) < 0) {
if (((x3 - x2) * (yp - y3)) - ((y3 - y2) * (xp - x3)) < 0) {
if (((x1 - x3) * (yp - y1)) - ((y1 - y3) * (xp - x1)) < 0) {
return true;
}
}
}
return false;
}
int main(void) {
double x1, x2, x3, y1, y2, y3;
double xp, yp;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
bool d;
d = judge(x1, x2, x3, y1, y2, y3, xp, yp);
if (d) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
| 1
| 343
|
#include <iostream>
using namespace std;
class Vector {
public:
double x;
double y;
Vector(double xx = 0, double yy = 0) {
x = xx;
y = yy;
}
Vector operator+(Vector p);
Vector operator-(Vector p);
};
Vector Vector::operator+(Vector p) {
Vector tmp;
tmp.x = x + p.x;
tmp.y = y + p.y;
return tmp;
}
Vector Vector::operator-(Vector p) {
Vector tmp;
tmp.x = x + p.x;
tmp.y = y + p.y;
return tmp;
}
bool check_hit(Vector A, Vector B, Vector C, Vector P);
int main() {
double x1, x2, x3, y1, y2, y3, x, y;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y) {
Vector A(x1, y1);
Vector B(x2, y2);
Vector C(x3, y3);
Vector P(x, y);
if (check_hit(A, B, C, P))
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
bool check_hit(Vector A, Vector B, Vector C, Vector P) {
Vector AB = B - A;
Vector BC = C - B;
Vector CA = A - C;
Vector AP = P - A;
Vector BP = P - B;
Vector CP = P - C;
double calc1 = AB.x * BP.y - AB.y * BP.x;
double calc2 = BC.x * CP.y - BC.y * CP.x;
double calc3 = CA.x * AP.y - CA.y * AP.x;
if ((calc1 > 0 && calc2 > 0 && calc3 > 0) ||
(calc1 < 0 && calc2 < 0 && calc3 < 0))
return true;
return false;
}
|
#include <iostream>
using namespace std;
class Vector {
public:
double x;
double y;
Vector(double xx = 0, double yy = 0) {
x = xx;
y = yy;
}
Vector operator+(Vector p);
Vector operator-(Vector p);
};
Vector Vector::operator+(Vector p) {
Vector tmp;
tmp.x = x + p.x;
tmp.y = y + p.y;
return tmp;
}
Vector Vector::operator-(Vector p) {
Vector tmp;
tmp.x = x - p.x;
tmp.y = y - p.y;
return tmp;
}
bool check_hit(Vector A, Vector B, Vector C, Vector P);
int main() {
double x1, x2, x3, y1, y2, y3, x, y;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y) {
Vector A(x1, y1);
Vector B(x2, y2);
Vector C(x3, y3);
Vector P(x, y);
if (check_hit(A, B, C, P))
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
bool check_hit(Vector A, Vector B, Vector C, Vector P) {
Vector AB = B - A;
Vector BC = C - B;
Vector CA = A - C;
Vector AP = P - A;
Vector BP = P - B;
Vector CP = P - C;
double calc1 = AB.x * BP.y - AB.y * BP.x;
double calc2 = BC.x * CP.y - BC.y * CP.x;
double calc3 = CA.x * AP.y - CA.y * AP.x;
if ((calc1 > 0 && calc2 > 0 && calc3 > 0) ||
(calc1 < 0 && calc2 < 0 && calc3 < 0))
return true;
return false;
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
| 1
| 407
|
#include <iostream>
#include <utility>
using namespace std;
int judge(pair<double, double> p1, pair<double, double> p2) {
int S = p1.first * p2.second - p2.first * p1.second;
if (0 < S)
return 1;
if (0 > S)
return -1;
if (0 == S)
return 0;
}
int main() {
pair<double, double> A, B, C, P;
while (cin >> A.first >> A.second >> B.first >> B.second >> C.first >>
C.second >> P.first >> P.second) {
pair<double, double> AB, BC, CA, AP, BP, CP;
AB = {B.first - A.first, B.second - A.second};
BC = {C.first - B.first, C.second - B.second};
CA = {A.first - C.first, A.second - C.second};
AP = {P.first - A.first, P.second - A.second};
BP = {P.first - B.first, P.second - B.second};
CP = {P.first - C.first, P.second - C.second};
if (judge(AP, AB) == judge(BP, BC) && judge(BP, BC) == judge(CP, CA) &&
judge(CP, CA) == judge(AP, AB)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <iostream>
#include <utility>
using namespace std;
int judge(pair<double, double> p1, pair<double, double> p2) {
double S = p1.first * p2.second - p2.first * p1.second;
if (0 < S)
return 1;
if (0 > S)
return -1;
if (0 == S)
return 0;
}
int main() {
pair<double, double> A, B, C, P;
while (cin >> A.first >> A.second >> B.first >> B.second >> C.first >>
C.second >> P.first >> P.second) {
pair<double, double> AB, BC, CA, AP, BP, CP;
AB = {B.first - A.first, B.second - A.second};
BC = {C.first - B.first, C.second - B.second};
CA = {A.first - C.first, A.second - C.second};
AP = {P.first - A.first, P.second - A.second};
BP = {P.first - B.first, P.second - B.second};
CP = {P.first - C.first, P.second - C.second};
if (judge(AP, AB) == judge(BP, BC) && judge(BP, BC) == judge(CP, CA) &&
judge(CP, CA) == judge(AP, AB)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
| 1
| 339
|
#include <cmath>
#include <complex>
#include <iostream>
using namespace std;
typedef complex<double> P;
double cross(P a, P b) { return (a.real() * b.imag() - a.imag() * b.real()); }
P vector_coord(P a, P b, P x) {
return P(-cross(b, x), cross(a, x)) / cross(a, b);
}
int main() {
double a1, b1, a2, b2, a3, b3, x1, y1;
while (cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3 >> x1 >> y1) {
P o = P(a1, b1);
P a = P(a2, b2) - o;
P b = P(a3, b3) - o;
P x = P(x1, y1);
P v = vector_coord(a, b, x);
if (0 < v.real() && 0 < v.imag() && v.real() + v.imag() < 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <cmath>
#include <complex>
#include <iostream>
using namespace std;
typedef complex<double> P;
double cross(P a, P b) { return (a.real() * b.imag() - a.imag() * b.real()); }
P vector_coord(P a, P b, P x) {
return P(-cross(b, x), cross(a, x)) / cross(a, b);
}
int main() {
double a1, b1, a2, b2, a3, b3, x1, y1;
while (cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3 >> x1 >> y1) {
P o = P(a1, b1);
P a = P(a2, b2) - o;
P b = P(a3, b3) - o;
P x = P(x1, y1) - o;
P v = vector_coord(a, b, x);
if (0 < v.real() && 0 < v.imag() && v.real() + v.imag() < 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
| 1
| 248
|
#include <iostream>
using namespace std;
class Vector2 {
public:
Vector2() {}
Vector2(double aX, double aY) : x(aX), y(aY) {}
double dot(Vector2 &a) { return (x * a.x) + (y * a.y); }
double x;
double y;
};
int main() {
Vector2 p0, p1, p2, q;
while (cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> q.x >> q.y) {
bool isInner = false;
Vector2 a(p1.x - p0.x, p1.y - p0.y);
Vector2 b(p2.x - p0.x, p2.y - p0.y);
Vector2 c(q.x - p0.x, q.y - p0.y);
double aa = a.dot(a);
double ab = a.dot(b);
double ac = a.dot(c);
double bb = b.dot(b);
double bc = b.dot(c);
double s = (bc * ab - ac * bb) / (ab * ab - aa * bb);
if ((s > 0.0) && (s < 1.0)) {
double t = (ac * ab - bc * aa) / (ab * ab - aa * bb);
if ((t > 0.0) && (s + t < 1.0)) {
isInner = true;
}
}
cout << (isInner ? "Yes" : "No") << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
class Vector2 {
public:
Vector2() {}
Vector2(double aX, double aY) : x(aX), y(aY) {}
double dot(Vector2 &a) { return (x * a.x) + (y * a.y); }
double x;
double y;
};
int main() {
Vector2 p0, p1, p2, q;
while (cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> q.x >> q.y) {
bool isInner = false;
Vector2 a(p1.x - p0.x, p1.y - p0.y);
Vector2 b(p2.x - p0.x, p2.y - p0.y);
Vector2 c(q.x - p0.x, q.y - p0.y);
double aa = a.dot(a);
double ab = a.dot(b);
double ac = a.dot(c);
double bb = b.dot(b);
double bc = b.dot(c);
double s = (bc * ab - ac * bb) / (ab * ab - aa * bb);
if ((s > 0.0) && (s < 1.0)) {
double t = (ac * ab - bc * aa) / (ab * ab - aa * bb);
if ((t > 0.0) && (s + t < 1.0)) {
isInner = true;
}
}
cout << (isInner ? "YES" : "NO") << endl;
}
return 0;
}
|
[["-", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
| 1
| 341
|
#include <complex>
#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define EPS 1e-15
using namespace std;
typedef complex<double> cd;
double s(cd a, cd b) { return abs(a.real() * b.imag() - a.imag() * b.real()); }
int main() {
cd a[4];
double x1, y1, x2, y2, x3, y3, xp, yp;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
a[0] = cd(x1, y1);
a[1] = cd(x2, y2);
a[2] = cd(x3, y3);
a[3] = cd(xp, yp);
if (abs(s(a[0] - a[3], a[1] - a[3]) + s(a[1] - a[3], a[2] - a[3]) +
s(a[2] - a[3], a[0] - a[3]) - s(a[1] - a[0], a[2] - a[0])) < EPS)
printf("IN\n");
else
printf("OUT\n");
}
return 0;
}
|
#include <complex>
#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define EPS 1e-10
using namespace std;
typedef complex<double> cd;
double s(cd a, cd b) { return abs(a.real() * b.imag() - a.imag() * b.real()); }
int main() {
cd a[4];
double x1, y1, x2, y2, x3, y3, xp, yp;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp,
&yp) != EOF) {
a[0] = cd(x1, y1);
a[1] = cd(x2, y2);
a[2] = cd(x3, y3);
a[3] = cd(xp, yp);
if (abs(s(a[0] - a[3], a[1] - a[3]) + s(a[1] - a[3], a[2] - a[3]) +
s(a[2] - a[3], a[0] - a[3]) - s(a[1] - a[0], a[2] - a[0])) < EPS)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 300
|
#include <stdio.h>
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp, p, q;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF)
;
{
if (x1 == 0 && y1 == 0) {
} else {
x2 -= x1;
x3 -= x1;
xp -= x1;
y2 -= y1;
y3 -= y1;
yp -= y1;
x1 = 0;
y1 = 0;
}
p = (y2 * xp - x2 * yp) / (x3 * y2 - x2 * y3);
q = (y3 * xp - x3 * yp) / (x2 * y3 - x3 * y2);
double w = p + q;
if (p >= 0 && q >= 0 && w < 1) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
double x1, y1, x2, y2, x3, y3, xp, yp, p, q;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
if (x1 == 0 && y1 == 0) {
} else {
x2 -= x1;
x3 -= x1;
xp -= x1;
y2 -= y1;
y3 -= y1;
yp -= y1;
x1 = 0;
y1 = 0;
}
p = (y2 * xp - x2 * yp) / (x3 * y2 - x2 * y3);
q = (y3 * xp - x3 * yp) / (x2 * y3 - x3 * y2);
double w = p + q;
if (p >= 0 && q >= 0 && w < 1) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 52, 8, 1, 0, 35]]
| 1
| 204
|
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)
int main() {
double x[4], y[4];
bool left, right;
double ax, ay, px, py;
while (1) {
for (int i = 0; i < 4; i++) {
if (!(cin >> x[i] >> y[i])) {
return 0;
}
}
left = false;
right = false;
for (int i = 0; i < 3; i++) {
ax = x[(i + 1) % 3] - x[i];
ay = y[(i + 1) % 3] - y[i];
px = x[3] - x[i];
py = y[3] - y[i];
if (ax * py - px * ay < 0) {
right = true;
break;
} else {
left = true;
}
}
if (left ^ right) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)
int main() {
double x[4], y[4];
bool left, right;
double ax, ay, px, py;
while (1) {
for (int i = 0; i < 4; i++) {
if (!(cin >> x[i] >> y[i])) {
return 0;
}
}
left = false;
right = false;
for (int i = 0; i < 3; i++) {
ax = x[(i + 1) % 3] - x[i];
ay = y[(i + 1) % 3] - y[i];
px = x[3] - x[i];
py = y[3] - y[i];
if (ax * py - px * ay < 0) {
right = true;
} else {
left = true;
}
}
if (left ^ right) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["-", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35]]
| 1
| 248
|
#include <cmath>
#include <cstdio>
using namespace std;
inline double out(double ax, double ay, double bx, double by) {
return bx * ay - by * ax;
}
int main(void) {
double x1, y1, x2, y2, x3, y3, px, py;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &px,
&py) != EOF) {
if ((out(px - x1, py - y1, x2 - x1, y2 - y1) > 0 &&
out(px - x2, py - y2, x3 - x2, y3 - y2) > 0 &&
out(px - x3, py - y3, x1 - x3, y1 - y3) > 0) &&
(out(px - x1, py - y1, x2 - x1, y2 - y1) < 0 &&
out(px - x2, py - y2, x3 - x2, y3 - y2) < 0 &&
out(px - x3, py - y3, x1 - x3, y1 - y3) < 0)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
#include <cmath>
#include <cstdio>
using namespace std;
inline double out(double ax, double ay, double bx, double by) {
return bx * ay - by * ax;
}
int main(void) {
double x1, y1, x2, y2, x3, y3, px, py;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &px,
&py) != EOF) {
if ((out(px - x1, py - y1, x2 - x1, y2 - y1) > 0 &&
out(px - x2, py - y2, x3 - x2, y3 - y2) > 0 &&
out(px - x3, py - y3, x1 - x3, y1 - y3) > 0) ||
(out(px - x1, py - y1, x2 - x1, y2 - y1) < 0 &&
out(px - x2, py - y2, x3 - x2, y3 - y2) < 0 &&
out(px - x3, py - y3, x1 - x3, y1 - y3) < 0)) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106]]
| 1
| 252
|
#include <iostream>
using namespace std;
int main(void) {
double x[4], y[4];
double xp, yp;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
bool l, r;
l = r = false;
x[3] = x[0];
y[3] = y[0];
for (int i = 0; i < 3; i++) {
double ax = x[i + 1] - x[i];
double ay = y[i + 1] - y[i];
double px = xp - x[i];
double py = yp - x[i];
if (ax * py - ay * px < 0)
r = true;
else
l = true;
}
cout << (r ^ l ? "YES" : "NO") << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main(void) {
double x[4], y[4];
double xp, yp;
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
bool l, r;
l = r = false;
x[3] = x[0];
y[3] = y[0];
for (int i = 0; i < 3; i++) {
double ax = x[i + 1] - x[i];
double ay = y[i + 1] - y[i];
double px = xp - x[i];
double py = yp - y[i];
if (ax * py - ay * px < 0)
r = true;
else
l = true;
}
cout << (r != l ? "YES" : "NO") << endl;
}
return 0;
}
|
[["-", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["-", 31, 16, 12, 23, 0, 41, 15, 16, 17, 140], ["+", 31, 16, 12, 23, 0, 41, 15, 16, 17, 79]]
| 1
| 208
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x1, x2, x3, xp, y1, y2, y3, yp, l12, l23, l13, l1p, l2p, l3p, S123,
S12p, S23p, S13p;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
l12 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
l23 = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
l13 = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
l1p = sqrt((x1 - xp) * (x1 - xp) + (y1 - yp) * (y1 - yp));
l2p = sqrt((x2 - xp) * (x2 - xp) + (y2 - yp) * (y2 - yp));
l3p = sqrt((x3 - xp) * (x3 - xp) + (y3 - yp) * (y3 - yp));
S123 = (sqrt((l12 + l23 + l13) * (-l12 + l23 + l13) * (l12 - l23 + l13) *
(l12 + l23 - l13))) /
4;
S12p = (sqrt((l12 + l2p + l1p) * (-l12 + l2p + l1p) * (l12 - l2p + l1p) *
(l12 + l2p - l1p))) /
4;
S13p = (sqrt((l1p + l3p + l13) * (-l1p + l3p + l13) * (l1p - l3p + l13) *
(l1p + l3p - l13))) /
4;
S23p = (sqrt((l2p + l23 + l3p) * (-l2p + l23 + l3p) * (l2p - l23 + l3p) *
(l2p + l23 - l3p))) /
4;
if (S123 - (S12p + S13p + S23p) < 0.1) {
puts("YES");
} else {
puts("NO");
}
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main(void) {
double x1, x2, x3, xp, y1, y2, y3, yp, l12, l23, l13, l1p, l2p, l3p, S123,
S12p, S23p, S13p;
while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3,
&xp, &yp) != EOF) {
l12 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
l23 = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
l13 = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
l1p = sqrt((x1 - xp) * (x1 - xp) + (y1 - yp) * (y1 - yp));
l2p = sqrt((x2 - xp) * (x2 - xp) + (y2 - yp) * (y2 - yp));
l3p = sqrt((x3 - xp) * (x3 - xp) + (y3 - yp) * (y3 - yp));
S123 = (sqrt((l12 + l23 + l13) * (-l12 + l23 + l13) * (l12 - l23 + l13) *
(l12 + l23 - l13))) /
4;
S12p = (sqrt((l12 + l2p + l1p) * (-l12 + l2p + l1p) * (l12 - l2p + l1p) *
(l12 + l2p - l1p))) /
4;
S13p = (sqrt((l1p + l3p + l13) * (-l1p + l3p + l13) * (l1p - l3p + l13) *
(l1p + l3p - l13))) /
4;
S23p = (sqrt((l2p + l23 + l3p) * (-l2p + l23 + l3p) * (l2p - l23 + l3p) *
(l2p + l23 - l3p))) /
4;
if (fabs(S123 - (S12p + S13p + S23p)) < 0.1) {
puts("YES");
} else {
puts("NO");
}
}
return 0;
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 15, 339, 51, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
| 1
| 463
|
#include <iostream>
double x[3], y[3], xp, yp;
int main() {
while (std::cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
int bit = 2;
for (int i = 0; i < 3; ++i) {
double tmp = (x[(i + 1) % 3] - x[i]) * (yp - y[i]) -
(y[(i + 1) % 3] - y[i]) * (xp - x[i]);
bit &= ~((tmp < 0) + 1);
}
std::cout << (bit ? "YES" : "NO") << "\n";
}
}
|
#include <iostream>
double x[3], y[3], xp, yp;
int main() {
while (std::cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp) {
int bit = 3;
for (int i = 0; i < 3; ++i) {
double tmp = (x[(i + 1) % 3] - x[i]) * (yp - y[i]) -
(y[(i + 1) % 3] - y[i]) * (xp - x[i]);
bit &= ~((tmp < 0) + 1);
}
std::cout << (bit ? "YES" : "NO") << "\n";
}
}
|
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13]]
| 1
| 176
|
#include <iostream>
using namespace std;
int gaiseki(double, double, double, double, double, double);
int main() {
double x[4], y[4];
int n[3], ans;
while (cin >> x[0]) {
cin >> y[0];
for (int i = 1; i < 4; i++) {
cin >> x[i] >> y[i];
}
//三角形の各辺の外積(求めたい点と始点、求めたい点と終点との外積)を取り、全て右か左だったら中に含まれる
for (int i = 0; i < 2; i++)
n[i] = gaiseki(x[i], y[i], x[i + 1], y[i + 1], x[3], y[3]);
n[2] = gaiseki(x[2], y[2], x[0], y[0], x[3], y[3]);
ans = 0;
for (int i = 0; i < 3; i++) {
ans += n[i];
}
if (ans == 3 || ans == -3)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
int gaiseki(double x1, double y1, double x2, double y2, double xp, double yp) {
double ans;
ans = xp * (y1 - y2) + x1 * (y2 - yp) + x2 * (yp - y1);
if (ans > 0)
return 1; //右側
else
return 0; //左側(=だと線上だが、今回は考えなくて良い)
}
|
#include <iostream>
using namespace std;
int gaiseki(double, double, double, double, double, double);
int main() {
double x[4], y[4];
int n[3], ans;
while (cin >> x[0]) {
cin >> y[0];
for (int i = 1; i < 4; i++) {
cin >> x[i] >> y[i];
}
//三角形の各辺の外積(求めたい点と始点、求めたい点と終点との外積)を取り、全て右か左だったら中に含まれる
for (int i = 0; i < 2; i++)
n[i] = gaiseki(x[i], y[i], x[i + 1], y[i + 1], x[3], y[3]);
n[2] = gaiseki(x[2], y[2], x[0], y[0], x[3], y[3]);
ans = 0;
for (int i = 0; i < 3; i++) {
ans += n[i];
}
if (ans == 3 || ans == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
int gaiseki(double x1, double y1, double x2, double y2, double xp, double yp) {
double ans;
ans = xp * (y1 - y2) + x1 * (y2 - yp) + x2 * (yp - y1);
if (ans > 0)
return 1; //右側
else
return 0; //左側(=だと線上だが、今回は考えなくて良い)
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 312
|
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
double pdot(pair<double, double> a, pair<double, double> b) {
return a.first * b.first + a.second * b.second;
}
int main() {
double a1, a2, b1, b2, c1, c2, p1, p2;
cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2 >> p1 >> p2;
pair<double, double> v0 = make_pair(c1 - a1, c2 - a2);
pair<double, double> v1 = make_pair(b1 - a1, b2 - a2);
pair<double, double> v2 = make_pair(p1 - a1, p2 - a2);
double dot00 = pdot(v0, v0), dot01 = pdot(v0, v1), dot02 = pdot(v0, v2),
dot11 = pdot(v1, v1);
double dot12 = pdot(v1, v2);
double id = 1.0 / (dot00 * dot11 - dot01 * dot01);
double u = (dot11 * dot02 - dot01 * dot12) * id;
double v = (dot00 * dot12 - dot01 * dot02) * id;
if (u >= 0 && v >= 0 && u + v < 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
double pdot(pair<double, double> a, pair<double, double> b) {
return a.first * b.first + a.second * b.second;
}
int main() {
double a1, a2, b1, b2, c1, c2, p1, p2;
while (cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2 >> p1 >> p2) {
pair<double, double> v0 = make_pair(c1 - a1, c2 - a2);
pair<double, double> v1 = make_pair(b1 - a1, b2 - a2);
pair<double, double> v2 = make_pair(p1 - a1, p2 - a2);
double dot00 = pdot(v0, v0), dot01 = pdot(v0, v1), dot02 = pdot(v0, v2),
dot11 = pdot(v1, v1);
double dot12 = pdot(v1, v2);
double id = 1.0 / (dot00 * dot11 - dot01 * dot01);
double u = (dot11 * dot02 - dot01 * dot12) * id;
double v = (dot00 * dot12 - dot01 * dot02) * id;
// cout<<u<<":"<<v<<endl;
if (u >= 0 && v >= 0 && u + v < 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 274
|
#include <iostream>
using namespace std;
typedef struct {
double x;
double y;
} vector;
bool ex_product(double x0, double y0, double x1, double y1, double xp,
double yp) {
vector a = {x1 - x0, y1 - y0};
vector b = {xp - x0, yp - y0};
return (a.x * b.y - a.y * b.x) >= 0;
}
int main(int argc, char *argv[]) {
double x1, y1, x2, y2, x3, y3, xp, yp;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp;
bool a = ex_product(x1, y1, x2, y2, xp, yp);
bool b = ex_product(x2, y2, x3, y3, xp, yp);
bool c = ex_product(x3, y3, x1, y1, xp, yp);
if ((a && b && c) || ((!a) && (!b) && (!c)))
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
|
#include <iostream>
using namespace std;
typedef struct {
double x;
double y;
} vector;
bool ex_product(double x0, double y0, double x1, double y1, double xp,
double yp) {
vector a = {x1 - x0, y1 - y0};
vector b = {xp - x0, yp - y0};
return (a.x * b.y - a.y * b.x) >= 0;
}
int main(int argc, char *argv[]) {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
bool a = ex_product(x1, y1, x2, y2, xp, yp);
bool b = ex_product(x2, y2, x3, y3, xp, yp);
bool c = ex_product(x3, y3, x1, y1, xp, yp);
if ((a && b && c) || ((!a) && (!b) && (!c)))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 238
|
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef complex<double> P;
const double EPS = 1e-8;
const double INF = 1e6;
double cross(P a, P b) { return imag(conj(a) * b); }
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
P v1 = P(x1, y1), v2 = P(x2, y2), v3 = P(x3, y3), vp = P(xp, yp);
if ((cross(vp - v1, vp - v2) > 0) && (cross(vp - v2, vp - v3) > 0) &&
(cross(vp - v3, vp - v1) > 0)) {
cout << "YES" << endl;
} else if ((cross(vp - v1, vp - v2) > 0) && (cross(vp - v2, vp - v3) > 0) &&
(cross(vp - v3, vp - v1) > 0)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef complex<double> P;
const double EPS = 1e-8;
const double INF = 1e6;
double cross(P a, P b) { return imag(conj(a) * b); }
int main() {
double x1, y1, x2, y2, x3, y3, xp, yp;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
P v1 = P(x1, y1), v2 = P(x2, y2), v3 = P(x3, y3), vp = P(xp, yp);
if ((cross(vp - v1, vp - v2) > 0) && (cross(vp - v2, vp - v3) > 0) &&
(cross(vp - v3, vp - v1) > 0)) {
cout << "YES" << endl;
} else if ((cross(vp - v1, vp - v2) < 0) && (cross(vp - v2, vp - v3) < 0) &&
(cross(vp - v3, vp - v1) < 0)) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
[["-", 51, 16, 31, 16, 31, 23, 0, 16, 17, 47], ["+", 51, 16, 31, 16, 31, 23, 0, 16, 17, 18], ["-", 51, 16, 31, 16, 12, 23, 0, 16, 17, 47], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 17, 18], ["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 47], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 18]]
| 1
| 273
|
def vector(x, y)
[y[0] * x[0], y[1] * x[1]]
end
def direction(x, y)
(x[0] * y[1] - x[1] * y[0]).positive? ? :+ : :-
end
$stdin.read.split("\n").each do |input|
a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a
result = [[a, b], [b, c], [c, a]].map do |s, e|
direction(vector(s, e), vector(s, d))
end
puts result.uniq.size == 1 ? 'YES' : 'NO'
end
|
def vector(x, y)
[y[0] - x[0], y[1] - x[1]]
end
def direction(x, y)
(x[0] * y[1] - x[1] * y[0]).positive? ? :+ : :-
end
$stdin.read.split("\n").each do |input|
a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a
result = [[a, b], [b, c], [c, a]].map do |s, e|
direction(vector(s, e), vector(e, d))
end
puts result.uniq.size == 1 ? 'YES' : 'NO'
end
|
[["-", 0, 735, 8, 736, 0, 516, 0, 738, 17, 48], ["+", 0, 735, 8, 736, 0, 516, 0, 738, 17, 33], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
| 4
| 178
|
readlines.each do |l|
x1, y1, x2, y2, x3, y3, xp, yp = l.split.map(&:to_f)
v1x = x2 - x1
v1y = y2 - y1
v2x = x3 - x1
v2y = y3 - y1
vpx = xp - x1
vpy = yp - y1
# (vpx, vpy) = t(v1x, v1y) + u(v2x, v2y)
t = (vpx * v2y - vpy * v2x) / (v1x * v2y - v1y * v2x)
u = (vpx * v1y - vpy * vpx) / (v1y * v2x - v2y * v1x)
if t.positive? && u.positive? && t + u < 1
puts 'YES'
else
puts 'NO'
end
end
|
readlines.each do |l|
x1, y1, x2, y2, x3, y3, xp, yp = l.split.map(&:to_f)
v1x = x2 - x1
v1y = y2 - y1
v2x = x3 - x1
v2y = y3 - y1
vpx = xp - x1
vpy = yp - y1
# (vpx, vpy) = t(v1x, v1y) + u(v2x, v2y)
t = (vpx * v2y - vpy * v2x) / (v1x * v2y - v1y * v2x)
u = (vpx * v1y - vpy * v1x) / (v1y * v2x - v2y * v1x)
if t.positive? && u.positive? && t + u < 1
puts 'YES'
else
puts 'NO'
end
end
|
[["-", 12, 738, 31, 739, 0, 738, 12, 738, 12, 22], ["+", 12, 738, 31, 739, 0, 738, 12, 738, 12, 22]]
| 4
| 130
|
import sys
def crossMulti(p1, p2):
return p1[0] * p2[1] - p1[1] * p2[0]
lines = sys.stdin.readlines()
for line in lines:
Zd = []
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)]
Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)]
for p in range(3):
Zd.append(crossMulti(Ps[p], Px[p]))
Zd = [x > 0 for x in Zd]
if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]):
print('Yes')
else:
print('No')
|
import sys
def crossMulti(p1, p2):
return p1[0] * p2[1] - p1[1] * p2[0]
lines = sys.stdin.readlines()
for line in lines:
Zd = []
x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)]
Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)]
for p in range(3):
Zd.append(crossMulti(Ps[p], Px[p]))
Zd = [x > 0 for x in Zd]
if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]):
print('YES')
else:
print('NO')
|
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
| 5
| 226
|
out=[]
while True:
try:
k=list(map(float,input().split(" ")))
except:
break
O_x,O_y=k[0],k[1]
A_x,A_y=k[2],k[3]
B_x,B_y=k[4],k[5]
P_x,P_y=k[6],k[7]
# P in triangle OAB
# iff s+t<1 and s>0 and t>0 (OP=sOA+tOB)
OA=(A_x-O_x,A_y-O_y)
OB=(B_x-O_x,B_y-O_y)
OP=(P_x-O_x,P_y-O_y)
keisuu=1/( OA[0]*OB[1] - OA[1]*OB[0] )
s=keisuu*( OB[1]*OP[0]-OB[0]*OP[1] )
t=keisuu*( -OA[1]*OP[0]+OA[0]*OP[1] )
if s>0 and t>0 and s+t>0:
out.append("YES")
else:
out.append("NO")
for i in out:
print(i)
|
out=[]
while True:
try:
k=list(map(float,input().split(" ")))
except:
break
O_x,O_y=k[0],k[1]
A_x,A_y=k[2],k[3]
B_x,B_y=k[4],k[5]
P_x,P_y=k[6],k[7]
# P in triangle OAB
# iff s+t<1 and s>0 and t>0 (OP=sOA+tOB)
OA=(A_x-O_x,A_y-O_y)
OB=(B_x-O_x,B_y-O_y)
OP=(P_x-O_x,P_y-O_y)
keisuu=1/( OA[0]*OB[1] - OA[1]*OB[0] )
s=keisuu*( OB[1]*OP[0]-OB[0]*OP[1] )
t=keisuu*( -OA[1]*OP[0]+OA[0]*OP[1] )
if s>0 and t>0 and s+t<1:
out.append("YES")
else:
out.append("NO")
for i in out:
print(i)
|
[["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 47], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 18], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]]
| 5
| 237
|
def Cramer(a11, a12, a13, a21, a22, a23):
den = a11 * a22 - a12 * a21
return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
print('YES' if u >= 0.0 and v >= 0.0 and u + v - 1.0 < 1e10 else 'NO')
except EOFError:
break
|
def Cramer(a11, a12, a13, a21, a22, a23):
den = a11 * a22 - a12 * a21
return (a13 * a22 - a12 * a23) / den, (a11 * a23 - a13 * a21) / den
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = [eval(item) for item in input().split()]
u, v = Cramer(x3 - x1, x2 - x1, xp - x1, y3 - y1, y2 - y1, yp - y1)
print('YES' if u >= 0.0 and v >= 0.0 and u + v <= 1.0 else 'NO')
except EOFError:
break
|
[["-", 0, 41, 0, 679, 12, 666, 0, 657, 17, 33], ["+", 3, 4, 0, 41, 0, 679, 12, 666, 667, 19], ["-", 3, 4, 0, 41, 0, 679, 12, 666, 667, 18], ["-", 3, 4, 0, 41, 0, 679, 12, 666, 0, 531]]
| 5
| 146
|
class point:
def __init__(self, x, y):
self.x = x
self.y = y
def sub(self, p):
return point(self.x - p.x, self.y - p.y)
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
A = point(x1, y1)
B = point(x2, y2)
C = point(x3, y3)
P = point(xp, yp)
AB = B.sub(A)
BP = P.sub(B)
BC = C.sub(B)
CP = P.sub(C)
CA = A.sub(C)
AP = P.sub(A)
c1 = AB.x * BP.y - AB.y * BP.x
c2 = BC.x * CP.y - BC.y * CP.x
c3 = CA.x * AP.y - CA.y * AP.x
if((c1 > 0) and (c2 > 0) and (c3 > 0) or (c1 < 0) and (c2 < 0) and (c3 < 0)): print(YES)
else: print(NO)
except:
break
|
class point:
def __init__(self, x, y):
self.x = x
self.y = y
def sub(self, p):
return point(self.x - p.x, self.y - p.y)
while True:
try:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, input().split()))
A = point(x1, y1)
B = point(x2, y2)
C = point(x3, y3)
P = point(xp, yp)
AB = B.sub(A)
BP = P.sub(B)
BC = C.sub(B)
CP = P.sub(C)
CA = A.sub(C)
AP = P.sub(A)
c1 = AB.x * BP.y - AB.y * BP.x
c2 = BC.x * CP.y - BC.y * CP.x
c3 = CA.x * AP.y - CA.y * AP.x
if((c1 > 0) and (c2 > 0) and (c3 > 0) or (c1 < 0) and (c2 < 0) and (c3 < 0)): print("YES")
else: print("NO")
except:
break
|
[["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 655]]
| 5
| 269
|
import sys
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, line.split()))
AB = [x2-x1, y2-y1]
BP = [xp-x2, yp-y2]
BC = [x3-x2, y3-y2]
CP = [xp-x3, yp-y3]
CA = [x1-x3, y1-y3]
BP = [xp-x1, yp-y1]
c1 = AB[0] * BP[1] - AB[1] * BP[0]
c2 = BC[0] * CP[1] - BC[1] * CP[0]
c3 = CA[0] * AP[1] - CA[1] * AP[0]
if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
print('YES')
else:
print('NO')
|
import sys
for line in sys.stdin:
x1, y1, x2, y2, x3, y3, xp, yp = list(map(float, line.split()))
AB = [x2-x1, y2-y1]
BP = [xp-x2, yp-y2]
BC = [x3-x2, y3-y2]
CP = [xp-x3, yp-y3]
CA = [x1-x3, y1-y3]
AP = [xp-x1, yp-y1]
c1 = AB[0] * BP[1] - AB[1] * BP[0]
c2 = BC[0] * CP[1] - BC[1] * CP[0]
c3 = CA[0] * AP[1] - CA[1] * AP[0]
if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
print('YES')
else:
print('NO')
|
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22]]
| 5
| 210
|
class vector(object):
def __init__(self,a,b):
self.x=b.x-a.x
self.y=b.y-a.y
@staticmethod
def cross_product(a,b):
return a.x*b.y-a.y*b.x
class vertex(object):
def __init__(self,a):
self.x=a[0]
self.y=a[1]
class circle(object):
def __init__(self,p,r):
self.px=p.x
self.py=p.y
self.r=r
class triangle(object):
def __init__(self,a,b,c):
self.a=a
self.b=b
self.c=c
import math
self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2)
self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2)
self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2)
c=self.ab
a=self.bc
b=self.ca
self.cosA=(b**2+c**2-a**2)/(2*b*c)
self.cosB=(a**2+c**2-b**2)/(2*a*c)
self.cosC=(b**2+a**2-c**2)/(2*b*a)
self.sinA=math.sqrt(1-self.cosA**2)
self.sinB=math.sqrt(1-self.cosB**2)
self.sinC=math.sqrt(1-self.cosC**2)
self.sin2A=2*self.sinA*self.cosA
self.sin2B=2*self.sinB*self.cosB
self.sin2C=2*self.sinC*self.cosC
def area(self):
import math
s=(self.ab+self.bc+self.ca)/2
S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca))
return S
def circumscribed(self):
R=self.ab/(2*self.sinC)
px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C)
py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C)
px=round(px,3)
py=round(py,3)
R=round(R,3)
p=vertex((px,py))
return circle(p,R)
def isin(self,p):
AB=vector(self.a,self.b)
BC=vector(self.b,self.c)
CA=vector(self.c,self.a)
AP=vector(self.a,p)
BP=vector(self.b,p)
CP=vector(self.c,p)
if (vector.cross_product(AB,AP)>0 and vector.cross_product(BC,BP)>0 and vector.cross_product(CA,CP)>0)or(vector.cross_product(AB,AP)<0 and vector.cross_product(BC,BP)<0 and vector.cross_product(CA,CP)<0):
return 'Yes'
else:return 'No'
A=[]
B=[]
C=[]
p=[]
import sys
for line in sys.stdin:
a,b,c,d,e,f,g,h=list(map(float,line.split()))
A.append(vertex((a,b)))
B.append(vertex((c,d)))
C.append(vertex((e,f)))
p.append(vertex((g,h)))
for i in range(len(A)):
Triangle=triangle(A[i],B[i],C[i])
print(Triangle.isin(p[i]))
|
class vector(object):
def __init__(self,a,b):
self.x=b.x-a.x
self.y=b.y-a.y
@staticmethod
def cross_product(a,b):
return a.x*b.y-a.y*b.x
class vertex(object):
def __init__(self,a):
self.x=a[0]
self.y=a[1]
class circle(object):
def __init__(self,p,r):
self.px=p.x
self.py=p.y
self.r=r
class triangle(object):
def __init__(self,a,b,c):
self.a=a
self.b=b
self.c=c
import math
self.ab=math.sqrt((self.a.x-self.b.x)**2+(self.a.y-self.b.y)**2)
self.bc=math.sqrt((self.b.x-self.c.x)**2+(self.b.y-self.c.y)**2)
self.ca=math.sqrt((self.c.x-self.a.x)**2+(self.c.y-self.a.y)**2)
c=self.ab
a=self.bc
b=self.ca
self.cosA=(b**2+c**2-a**2)/(2*b*c)
self.cosB=(a**2+c**2-b**2)/(2*a*c)
self.cosC=(b**2+a**2-c**2)/(2*b*a)
self.sinA=math.sqrt(1-self.cosA**2)
self.sinB=math.sqrt(1-self.cosB**2)
self.sinC=math.sqrt(1-self.cosC**2)
self.sin2A=2*self.sinA*self.cosA
self.sin2B=2*self.sinB*self.cosB
self.sin2C=2*self.sinC*self.cosC
def area(self):
import math
s=(self.ab+self.bc+self.ca)/2
S=math.sqrt(s*(s-self.ab)*(s-self.bc)*(s-self.ca))
return S
def circumscribed(self):
R=self.ab/(2*self.sinC)
px=(self.sin2A*self.a.x+self.sin2B*self.b.x+self.sin2C*self.c.x)/(self.sin2A+self.sin2B+self.sin2C)
py=(self.sin2A*self.a.y+self.sin2B*self.b.y+self.sin2C*self.c.y)/(self.sin2A+self.sin2B+self.sin2C)
px=round(px,3)
py=round(py,3)
R=round(R,3)
p=vertex((px,py))
return circle(p,R)
def isin(self,p):
AB=vector(self.a,self.b)
BC=vector(self.b,self.c)
CA=vector(self.c,self.a)
AP=vector(self.a,p)
BP=vector(self.b,p)
CP=vector(self.c,p)
if (vector.cross_product(AB,AP)>0 and vector.cross_product(BC,BP)>0 and vector.cross_product(CA,CP)>0)or(vector.cross_product(AB,AP)<0 and vector.cross_product(BC,BP)<0 and vector.cross_product(CA,CP)<0):
return 'YES'
else:return 'NO'
A=[]
B=[]
C=[]
p=[]
import sys
for line in sys.stdin:
a,b,c,d,e,f,g,h=list(map(float,line.split()))
A.append(vertex((a,b)))
B.append(vertex((c,d)))
C.append(vertex((e,f)))
p.append(vertex((g,h)))
for i in range(len(A)):
Triangle=triangle(A[i],B[i],C[i])
print(Triangle.isin(p[i]))
|
[["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["+", 0, 57, 64, 196, 0, 37, 0, 557, 0, 6], ["-", 75, 76, 8, 196, 0, 37, 0, 557, 0, 6], ["+", 75, 76, 8, 196, 0, 37, 0, 557, 0, 6]]
| 5
| 977
|
class Point(object):
x = 0.0
y = 0.0
def __init__(self, x, y):
self.x = x
self.y = y
def __sub__(left, right):
return Point(left.x - right.x, left.y - right.y)
#cross
def __mul__(left, right):
return left.x * right.y + left.y * right.x
while True:
try:
(x1, y1, x2, y2, x3, y3, xp, yp) = list(map(float, input().split()))
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p3 = Point(x3, y3)
pp = Point(xp, yp)
p12 = p1 - p2
p23 = p2 - p3
p31 = p3 - p1
pp1 = pp - p1
pp2 = pp - p2
pp3 = pp - p3
c1 = (p12 * pp1 < 0.0)
c2 = (p23 * pp2 < 0.0)
c3 = (p31 * pp3 < 0.0)
if(c1 ^ c2 or c2 ^ c3):
print('NO')
else:
print('YES')
except EOFError:
break
|
class Point(object):
x = 0.0
y = 0.0
def __init__(self, x, y):
self.x = x
self.y = y
def __sub__(left, right):
return Point(left.x - right.x, left.y - right.y)
#cross
def __mul__(left, right):
return left.x * right.y - left.y * right.x
while True:
try:
(x1, y1, x2, y2, x3, y3, xp, yp) = list(map(float, input().split()))
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p3 = Point(x3, y3)
pp = Point(xp, yp)
p12 = p1 - p2
p23 = p2 - p3
p31 = p3 - p1
pp1 = pp - p1
pp2 = pp - p2
pp3 = pp - p3
c1 = (p12 * pp1 < 0.0)
c2 = (p23 * pp2 < 0.0)
c3 = (p31 * pp3 < 0.0)
if(c1 ^ c2 or c2 ^ c3):
print('NO')
else:
print('YES')
except EOFError:
break
|
[["-", 0, 14, 8, 196, 0, 37, 0, 657, 17, 72], ["+", 0, 14, 8, 196, 0, 37, 0, 657, 17, 33]]
| 5
| 240
|
#include <stdio.h>
int main() {
int d, e, f;
while (scanf("%d", &d) != EOF) {
f = 0;
for (e = 1; e * d <= 600; e++)
f = f + d * d * (e - 1) * d * (e - 1);
printf("%d", f);
}
return 0;
}
|
#include <stdio.h>
int main() {
int d, e, f;
while (scanf("%d", &d) != EOF) {
f = 0;
for (e = 1; e * d <= 600; e++)
f = f + d * d * (e - 1) * d * (e - 1);
printf("%d\n", f);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 84
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i, j, k, l, n, ans = 0;
int main() {
while (scanf("%d", &n) != EOF) {
for (i = 1; i <= 600 / n; i++) {
ans += (n * i) * (n * i) * n;
}
printf("%d\n", ans);
ans = 0;
}
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i, j, k, l, n, ans = 0;
int main() {
while (scanf("%d", &n) != EOF) {
for (i = 1; i < 600 / n; i++) {
ans += (n * i) * (n * i) * n;
}
printf("%d\n", ans);
ans = 0;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
| 0
| 93
|
#include <stdio.h>
int main() {
int a, b = 0, ans;
while (scanf("%d", &a) != EOF) {
b = a;
ans = 0;
while (b < 600) {
ans += a * b * b;
b += a;
}
printf("%d", ans);
}
return 0;
}
|
#include <stdio.h>
int main() {
int a, b = 0, ans;
while (scanf("%d", &a) != EOF) {
b = a;
ans = 0;
while (b < 600) {
ans += a * b * b;
b += a;
}
printf("%d\n", ans);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 73
|
#include <stdio.h>
int main() {
int a = 0, d, c;
while (~scanf("%d", &d)) {
for (c = 0; c <= 600; c += d) {
a += c * c * d;
}
printf("%d\n", a);
a = 0;
}
return 0;
}
|
#include <stdio.h>
int main() {
int a = 0, d, c;
while (~scanf("%d", &d)) {
for (c = 0; c < 600; c += d) {
a += c * c * d;
}
printf("%d\n", a);
a = 0;
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
| 0
| 73
|
d, x;
main(a) {
for (; ~scanf("%d", &d);) {
for (x = 0; x < 600; x += d)
a += x * x * d;
printf("%d\n", a);
}
}
|
d, x;
main(a) {
for (; ~scanf("%d", &d);) {
a = 0;
for (x = 0; x < 600; x += d)
a += x * x * d;
printf("%d\n", a);
}
}
|
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
| 0
| 59
|
#include <math.h>
#include <stdio.h>
int main() {
int divisor[10000000000];
int temp, i;
int area[10000000000];
for (temp = 0; scanf("%d", &divisor[temp]) != EOF; temp++) {
for (i = 1; i <= (600 - divisor[temp]) / divisor[temp]; i++) {
area[temp] = area[temp] + divisor[temp] * pow(i * divisor[temp], 2);
}
printf("%d\n", area[temp]);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
int main() {
int divisor[10000];
int temp, i;
int area[10000];
for (temp = 0; scanf("%d", &divisor[temp]) != EOF; temp++) {
for (i = 1; i <= (600 - divisor[temp]) / divisor[temp]; i++) {
area[temp] = area[temp] + divisor[temp] * pow(i * divisor[temp], 2);
}
printf("%d\n", area[temp]);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
| 0
| 123
|
#include <stdio.h>
int quadratic_function(int factor) { return factor * factor; }
int main() {
int divisor[100];
int temp, j, i;
int area[100];
for (temp = 0; scanf("%d", &divisor[temp]) != EOF; temp++)
;
for (j = 0; j < temp; j++) {
for (i = 1; i <= (600 - divisor[j]) / divisor[j]; i++) {
area[j] = area[j] + divisor[j] * quadratic_function(i * divisor[j]);
}
printf("%d\n", area[j]);
}
return 0;
}
|
#include <stdio.h>
int quadratic_function(int factor) { return factor * factor; }
int main() {
int divisor[10000];
int temp, j, i;
int area[10000];
for (temp = 0; scanf("%d", &divisor[temp]) != EOF; temp++)
;
for (j = 0; j < temp; j++) {
for (i = 1; i <= (600 - divisor[j]) / divisor[j]; i++) {
area[j] = area[j] + divisor[j] * quadratic_function(i * divisor[j]);
}
printf("%d\n", area[j]);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
| 0
| 148
|
#include <stdio.h>
int main() {
int s, i, d;
while (!scanf("%d", &d)) {
s = 0;
for (i = 1; d * i < 600; i++) {
s += d * i * d * i * d;
}
printf("%d\n", s);
}
return 0;
}
|
#include <stdio.h>
int main() {
int s, i, d;
while (scanf("%d", &d) != EOF) {
s = 0;
for (i = 1; d * i < 600; i++) {
s += (d * i * d * i * d);
}
printf("%d\n", s);
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 23, 0, 91, 17, 111], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 79], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 25]]
| 0
| 76
|
#include <stdio.h>
int main() {
int d;
int ans = 0;
int ss;
int i;
while (scanf("%d", &d) != EOF) {
for (i = 1; i <= (600 - d) / d; i++) {
ss = i * d * d * d;
ans += ss;
}
printf("%d\n", ans);
}
return 0;
}
|
#include <stdio.h>
int main() {
int d;
int ans = 0;
int ss;
int i;
while (scanf("%d", &d) != EOF) {
for (i = 1; i <= (600 - d) / d; i++) {
ss = i * i * d * d * d;
ans += ss;
}
printf("%d\n", ans);
ans = 0;
}
return 0;
}
|
[["+", 12, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 48], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]]
| 0
| 86
|
#include <stdio.h>
#define N 600
int main(void) {
int d[100], i = 0, j = 0, k = 0;
int s;
while (scanf("%d", &d[i]) != EOF) {
i++;
}
for (j = 0; j <= i; j++) {
k = N / d[j] - 1;
s = k * (k + 1) * (2 * k + 1) / 6 * d[j] * d[j] * d[j];
printf("%d\n", s);
}
return 0;
}
|
#include <stdio.h>
#define N 600
int main(void) {
int d[100], i = 0, j = 0, k = 0;
int s;
while (scanf("%d", &d[i]) != EOF) {
i++;
}
for (j = 0; j < i; j++) {
k = N / d[j] - 1;
s = k * (k + 1) * (2 * k + 1) / 6 * d[j] * d[j] * d[j];
printf("%d\n", s);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
| 0
| 129
|
#include <math.h>
#include <stdio.h>
#define f(x) x *x
int main(void) {
int d, sum = 0;
double x;
while (scanf("%d", &d) != EOF) {
for (x = 0; x < 600 / d; x++) {
sum += f(x * d) * d;
}
printf("%d\n", sum);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
#define f(x) x *x
int main(void) {
int d, sum = 0;
double x;
while (scanf("%d", &d) != EOF) {
sum = 0;
for (x = 0; x < 600 / d; x++) {
sum += f(x * d) * d;
}
printf("%d\n", sum);
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 0
| 84
|
#include <iostream>
using namespace std;
int main() {
int d, tmp, s = 0;
while (cin >> d) {
tmp = d;
for (; d <= 600 - tmp; d += tmp) {
s += d * d * tmp;
}
cout << s << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d, tmp, s = 0;
while (cin >> d) {
tmp = d;
for (; d <= 600 - tmp; d += tmp) {
s += d * d * tmp;
}
cout << s << endl;
s = 0;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 65
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int area = 0;
for (int x; x < 600; x += d) {
area += (x * x) * d;
}
cout << area << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d;
while (cin >> d) {
int area = 0;
for (int x = 0; x < 600; x += d) {
area += (x * x) * d;
}
cout << area << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 7, 10, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
| 1
| 62
|
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int d, newd, s = 0;
while (cin >> d) {
newd = d;
while (newd < 600) {
s += d * pow(newd, 2);
newd += d;
}
cout << s << endl;
}
}
|
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int d, newd, s = 0;
while (cin >> d) {
s = 0;
newd = d;
while (newd < 600) {
s += d * pow(newd, 2);
newd += d;
}
cout << s << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 64
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int d;
while (cin >> d) {
int s = 0;
for (int i = 0; i < 600; i += d) {
s += i * i * d;
}
cout << d << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int d, s;
while (cin >> d) {
s = 0;
for (int i = 0; i < 600; i += d) {
s += i * i * d;
}
cout << s << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 64
|
#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
int f(int x) { return x * x; }
int main() {
int d;
while (cin >> d) {
int sum = 0;
int x = 0;
while (x < 600) {
sum += f(x);
x += d;
}
cout << sum << endl;
}
}
|
#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
int f(int x) { return x * x; }
int main() {
int d;
while (cin >> d) {
int sum = 0;
int x = 0;
while (x < 600) {
sum += f(x) * d;
x += d;
}
cout << sum << endl;
}
}
|
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
| 1
| 75
|
#include <iostream>
int main() {
int d, area;
while (std::cin >> d) {
area = 0;
for (int i = 1; i < 600 / d; ++i)
area += i * i * d * d;
std::cout << area << std::endl;
}
return 0;
}
|
#include <iostream>
int main() {
int d, area;
while (std::cin >> d) {
area = 0;
for (int i = 1; i < 600 / d; ++i)
area += i * i * d * d * d;
std::cout << area << std::endl;
}
return 0;
}
|
[["+", 0, 7, 8, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 7, 8, 1, 0, 11, 12, 16, 12, 22]]
| 1
| 66
|
#include <iostream>
using namespace std;
long long int f(int a) { return (long long int)a * a; }
int main() {
int d, od, num;
long long int s = 0;
while (cin >> d) {
num = 600 / d;
od = d;
for (int i = 0; i < num; i++) {
s += od * f(d);
d += od;
}
cout << s << endl;
s = 0;
}
return 0;
}
|
#include <iostream>
using namespace std;
long long int f(int a) { return (long long int)a * a; }
int main() {
int d, od, num;
long long int s = 0;
while (cin >> d) {
num = 600 / d;
od = d;
d = 0;
for (int i = 0; i < num; i++) {
s += od * f(d);
d += od;
}
cout << s << endl;
s = 0;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 106
|
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int d, ans;
while (cin >> d) {
for (int i = 0; i < 600; i += d) {
ans += d * i * i;
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int d, ans;
while (cin >> d) {
ans = 0;
for (int i = 0; i < 600; i += d) {
ans += d * i * i;
}
cout << ans << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 63
|
#include <iostream>
using namespace std;
int main() {
int d, x, y, s = 0;
while (cin >> d) {
x = 600;
for (x -= d; x > 0; x -= d) {
y = x * x;
s += y * d;
}
cout << s << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int d, x, y, s = 0;
while (cin >> d) {
x = 600;
s = 0;
for (x -= d; x > 0; x -= d) {
y = x * x;
s += y * d;
}
cout << s << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 72
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int d;
cin >> d;
int result = 0;
for (int i = 1; d * i <= 600 - d; i++) {
result += (i * d) * (i * d) * d;
}
cout << result << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int d;
while (cin >> d) {
int result = 0;
for (int i = 1; d * i <= 600 - d; i++) {
result += (i * d) * (i * d) * d;
}
cout << result << endl;
}
return 0;
}
|
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 69
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.