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 sys
lc=lambda n:int((n**2+n+2)/2)
[print(i) for i in [lc(int(j)) for j in sts.stdin]]
|
import sys
lc=lambda n:int((n**2+n+2)/2)
[print(i) for i in [lc(int(j)) for j in sys.stdin]]
|
[["-", 0, 659, 12, 658, 0, 659, 12, 319, 500, 22], ["+", 0, 659, 12, 658, 0, 659, 12, 319, 500, 22]]
| 5
| 45
|
while True:
try:
n = int(input())
print((a**2+a+2)/2)
except EOFError: break
|
while True:
try:
a = int(input())
print((a**2+a+2)/2)
except EOFError: break
|
[["-", 0, 246, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 246, 8, 196, 0, 1, 0, 662, 31, 22]]
| 5
| 31
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
String[] input = line.split(" ");
double[] d = new double[8];
for (int i = 0; i < 8; i++) {
d[i] = Double.parseDouble(input[i]);
}
// (d[3]-d[1])*(d[7]-d[5]) == -1 * (d[2]-d[0]) * (d[6]-d[4])
if ((d[3] - d[1]) * (d[7] - d[5]) + (d[2] - d[0]) * (d[6] - d[4]) <=
1e-10) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
String[] input = line.split(" ");
double[] d = new double[8];
for (int i = 0; i < 8; i++) {
d[i] = Double.parseDouble(input[i]);
}
// (d[3]-d[1])*(d[7]-d[5]) == -1 * (d[2]-d[0]) * (d[6]-d[4])
if (Math.abs((d[3] - d[1]) * (d[7] - d[5]) +
(d[2] - d[0]) * (d[6] - d[4])) < 1e-10) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
|
[["+", 0, 57, 15, 15, 0, 16, 31, 492, 500, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 492, 0, 131], ["+", 0, 57, 15, 15, 0, 16, 31, 492, 141, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 19], ["+", 15, 15, 0, 16, 31, 492, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 18]]
| 3
| 209
|
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try {
System.setIn(new FileInputStream("src/aoj0058/input.txt"));
System.setOut(
new PrintStream(new FileOutputStream("src/aoj0058/result.txt")));
} catch (FileNotFoundException e) {
}
new Main().run();
}
void run() {
Scanner sc = new Scanner(System.in);
for (; sc.hasNext();) {
double X[] = new double[4], Y[] = new double[4];
for (int i = 0; i < 4; i++) {
X[i] = sc.nextDouble();
Y[i] = sc.nextDouble();
}
double dx1 = X[0] - X[1];
double dy1 = Y[0] - Y[1];
double dx2 = X[2] - X[3];
double dy2 = Y[2] - Y[3];
boolean res = (dx1 * dx2 + dy1 * dy2) < 1e-3;
System.out.println(res ? "YES" : "NO");
}
}
void debug(Object... os) { System.err.println(deepToString(os)); }
}
|
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try {
System.setIn(new FileInputStream("src/aoj0058/input.txt"));
System.setOut(
new PrintStream(new FileOutputStream("src/aoj0058/result.txt")));
} catch (FileNotFoundException e) {
}
new Main().run();
}
void run() {
Scanner sc = new Scanner(System.in);
for (; sc.hasNext();) {
double X[] = new double[4], Y[] = new double[4];
for (int i = 0; i < 4; i++) {
X[i] = sc.nextDouble();
Y[i] = sc.nextDouble();
}
double dx1 = X[0] - X[1];
double dy1 = Y[0] - Y[1];
double dx2 = X[2] - X[3];
double dy2 = Y[2] - Y[3];
boolean res = abs(dx1 * dx2 + dy1 * dy2) < 1e-8;
System.out.println(res ? "YES" : "NO");
}
}
void debug(Object... os) { System.err.println(deepToString(os)); }
}
|
[["+", 0, 503, 49, 200, 51, 16, 31, 492, 141, 22], ["-", 8, 196, 0, 503, 49, 200, 51, 16, 12, 515], ["+", 8, 196, 0, 503, 49, 200, 51, 16, 12, 515]]
| 3
| 293
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
double n, ans;
cin >> n;
ans = n;
for (int i = 2; i <= 10; i++) {
if (i % 2 == 1) {
n = n / 3.0;
ans += n;
} else {
n *= 2.0;
ans += n;
}
}
printf("%.6f\n", ans);
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
double n, ans;
while (cin >> n) {
ans = n;
for (int i = 2; i <= 10; i++) {
if (i % 2 == 1) {
n = n / 3.0;
ans += n;
} else {
n *= 2.0;
ans += n;
}
}
printf("%.6f\n", ans);
}
}
|
[["+", 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
| 84
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
double n;
while (cin >> n) {
double ans = n;
for (int i = 2; i <= 10; i++) {
if (i % 2 == 0) {
n *= 2;
ans += n;
} else {
n /= 3;
ans += n;
}
}
printf("%.8f", ans);
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
double n;
while (cin >> n) {
double ans = n;
for (int i = 2; i <= 10; i++) {
if (i % 2 == 0) {
n *= 2;
ans += n;
} else {
n /= 3;
ans += n;
}
}
printf("%.8f\n", ans);
}
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 88
|
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
double a;
double sum;
while (cin >> a) {
sum = 0;
for (int i = 2; i <= 10; i++) {
sum += a;
if (i % 2 == 0) {
a *= 2;
} else {
a /= 3;
}
cout << setprecision(10);
}
cout << sum << endl;
}
return 0;
}
|
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
double a;
double sum;
while (cin >> a) {
sum = 0;
for (int i = 1; i <= 10; i++) {
sum += a;
if (i % 2 == 0) {
a /= 3;
} else {
a *= 2;
}
cout << setprecision(10);
}
cout << sum << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 108], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 90], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 108], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13]]
| 1
| 89
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
long double a, before, sum;
while (cin >> a) {
before = a;
sum = before;
for (int i = 2; i <= 10; i++) {
if (i % 2 == 0)
before *= 2;
else
before /= 3;
sum += before;
}
printf("%.8f\n", sum);
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main(void) {
double a, before, sum;
while (cin >> a) {
before = a;
sum = before;
for (int i = 2; i <= 10; i++) {
if (i % 2 == 0)
before *= 2;
else
before /= 3;
sum += before;
}
printf("%.8f\n", sum);
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 89
|
while gets
sum = $_.to_f
9.times do |i|
i % 2 == 0 ? a *= 2 : a /= 3
sum += a
end
puts sum
end
|
while gets
a, sum = $_.to_f
sum = a
9.times do |i|
i % 2 == 0 ? a *= 2 : a /= 3
sum += a
end
puts sum
end
|
[["+", 0, 89, 8, 170, 0, 662, 31, 761, 0, 22], ["+", 0, 89, 8, 170, 0, 662, 31, 761, 0, 21], ["+", 0, 493, 0, 89, 8, 170, 0, 662, 31, 22], ["+", 0, 493, 0, 89, 8, 170, 0, 662, 0, 32], ["+", 0, 493, 0, 89, 8, 170, 0, 662, 12, 22]]
| 4
| 34
|
while gets
sum = $_.to_f
9.times do |i|
i % 2 == 0 ? a *= 2 : a /= 3
sum += a
end
puts sum
end
|
while gets
sum = a = $_.to_f
9.times do |i|
i % 2 == 0 ? a *= 2 : a /= 3
sum += a
end
puts sum
end
|
[["+", 0, 89, 8, 170, 0, 662, 12, 662, 31, 22], ["+", 0, 89, 8, 170, 0, 662, 12, 662, 0, 32]]
| 4
| 34
|
import sys
for e in sys.stdin:
t=[a,
a*2,
a*2/3,
a*2/3*2,
a*2/3*2/3,
a*2/3*2/3*2,
a*2/3*2/3*2/3,
a*2/3*2/3*2/3*2,
a*2/3*2/3*2/3*2/3,
a*2/3*2/3*2/3*2/3*2]
print(sum(t))
|
import sys
for e in sys.stdin:
a=float(e)
t=[a,
a*2,
a*2/3,
a*2/3*2,
a*2/3*2/3,
a*2/3*2/3*2,
a*2/3*2/3*2/3,
a*2/3*2/3*2/3*2,
a*2/3*2/3*2/3*2/3,
a*2/3*2/3*2/3*2/3*2]
print(sum(t))
|
[["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
| 5
| 129
|
import sys
for x in sys.stdin.readlines():
a=float(x.rstrip())
s=[0.0]*10
for i in range(1,10):
if i%2 != 0: s[i]=s[i-1]*2.0
else: s[i]=s[i-1]/3.0
print(sum(s))
|
import sys
for x in sys.stdin.readlines():
a=float(x.rstrip())
s=[0.0]*10
s[0]=a
for i in range(1,10):
if i%2 != 0: s[i]=s[i-1]*2.0
else: s[i]=s[i-1]/3.0
print(sum(s))
|
[["+", 8, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 206, 612], ["+", 8, 196, 0, 1, 0, 662, 31, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 22]]
| 5
| 82
|
import java.util.*;
class Main {
Scanner sc = new Scanner(System.in);
public void run() {
HashSet<Integer> primes = new HashSet<Integer>();
for (int i = 2; i < 50000; i++) {
boolean isprime = true;
for (int prime : primes) {
if (i % prime == 0) {
isprime = false;
break;
}
if (prime * prime > i) {
break;
}
}
if (isprime) {
primes.add(i);
}
}
boolean[] hash = new boolean[50000];
for (int prime : primes) {
hash[prime] = true;
}
while (sc.hasNext()) {
int n = sc.nextInt();
if (n == 0)
break;
int c = 0;
for (int a = 1; a <= n / 2; a++) {
int b = n - a;
if (hash[a] && hash[b]) {
c++;
}
}
ln(c);
}
}
public static void main(String[] args) { new Main().run(); }
public static void pr(Object o) { System.out.print(o); }
public static void ln(Object o) { System.out.println(o); }
public static void ln() { System.out.println(); }
}
|
import java.util.*;
class Main {
Scanner sc = new Scanner(System.in);
public void run() {
LinkedList<Integer> primes = new LinkedList<Integer>();
for (int i = 2; i <= 50000; i++) {
boolean isprime = true;
for (int prime : primes) {
if (i % prime == 0) {
isprime = false;
break;
}
if (prime * prime > i) {
break;
}
}
if (isprime) {
primes.add(i);
}
}
boolean[] hash = new boolean[50001];
for (int prime : primes) {
hash[prime] = true;
}
while (sc.hasNext()) {
int n = sc.nextInt();
if (n == 0)
break;
int c = 0;
for (int a = 2; a <= n / 2; a++) {
int b = n - a;
if (hash[a] && hash[b]) {
c++;
}
}
ln(c);
}
}
public static void main(String[] args) { new Main().run(); }
public static void pr(Object o) { System.out.print(o); }
public static void ln(Object o) { System.out.println(o); }
public static void ln() { System.out.println(); }
}
|
[["-", 0, 195, 8, 196, 0, 503, 39, 513, 0, 78], ["+", 0, 195, 8, 196, 0, 503, 39, 513, 0, 78], ["-", 0, 503, 49, 200, 51, 230, 39, 513, 0, 78], ["+", 0, 503, 49, 200, 51, 230, 39, 513, 0, 78], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
| 3
| 295
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
static Main main = new Main();
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
Prime prime = main.new Prime(50000);
while (!(line = br.readLine()).equals("0")) {
int n = Integer.parseInt(line);
int c = 0;
for (int v : prime.values) {
if (v * 2 > n) {
break;
}
if (prime.indexes[v] && prime.indexes[n - v]) {
c++;
}
}
System.out.println(c);
}
}
class Prime {
int max;
int count = 0;
boolean[] indexes;
int[] values;
Prime(int max) {
this.max = max;
setIndexes();
setValues();
}
void setIndexes() {
indexes = new boolean[max + 1];
Arrays.fill(indexes, true);
for (int i = 2; i < max + 1; i++) {
if (indexes[i]) {
count++;
for (int j = 2; j <= max / i; j++) {
indexes[i * j] = false;
}
}
}
}
void setValues() {
int[] values = new int[count];
int j = 0;
for (int i = 2; i < indexes.length; i++) {
if (indexes[i]) {
values[j] = i;
j++;
}
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
static Main main = new Main();
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
Prime prime = main.new Prime(50000);
while (!(line = br.readLine()).equals("0")) {
int n = Integer.parseInt(line);
int c = 0;
for (int v : prime.values) {
if (v * 2 > n) {
break;
}
if (prime.indexes[v] && prime.indexes[n - v]) {
c++;
}
}
System.out.println(c);
}
}
class Prime {
int max;
int count = 0;
boolean[] indexes;
int[] values;
Prime(int max) {
this.max = max;
setIndexes();
setValues();
}
void setIndexes() {
indexes = new boolean[max + 1];
Arrays.fill(indexes, true);
for (int i = 2; i < max + 1; i++) {
if (indexes[i]) {
count++;
for (int j = 2; j <= max / i; j++) {
indexes[i * j] = false;
}
}
}
}
void setValues() {
values = new int[count];
int j = 0;
for (int i = 2; i < max + 1; i++) {
if (indexes[i]) {
values[j] = i;
j++;
}
}
}
}
}
|
[["-", 8, 196, 0, 503, 39, 224, 468, 506, 0, 507], ["-", 8, 196, 0, 503, 39, 224, 497, 497, 0, 70], ["-", 8, 196, 0, 503, 39, 224, 497, 497, 0, 73], ["-", 8, 196, 0, 7, 15, 16, 12, 509, 500, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 509, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 509, 119, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
| 3
| 364
|
#include <math.h>
#include <stdio.h>
#include <string.h>
char prime[50001];
void eratosthenes() {
int i, l, j, d;
memset(prime, 1, sizeof(prime));
prime[0] = prime[1] = 0;
for (i = 3, l = (int)sqrt(50000) + 1; i < l; i++) {
if (prime[i] == 1) {
for (d = i * 2, j = i + d; j <= 50000; j += d) {
prime[j] = 0;
}
}
}
}
int main(void) {
int n, i, pat;
eratosthenes();
while (scanf("%d", &n) == 1 && n) {
if (n & 1) {
if (prime[n - 2]) {
puts("1");
} else {
puts("0");
}
continue;
}
for (i = n - 1, pat = 0; i >= n / 2; i -= 2) {
if (prime[i] && prime[n - i]) {
pat++;
}
}
printf("%d\n", pat);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
#include <string.h>
char prime[50001];
void eratosthenes() {
int i, l, j, d;
memset(prime, 1, sizeof(prime));
prime[0] = prime[1] = 0;
for (i = 3, l = (int)sqrt(50000) + 1; i < l; i++) {
if (prime[i] == 1) {
for (d = i * 2, j = i + d; j <= 50000; j += d) {
prime[j] = 0;
}
}
}
}
int main(void) {
int n, i, pat;
eratosthenes();
while (scanf("%d", &n) == 1 && n) {
if (n & 1 || n == 4) {
if (prime[n - 2]) {
puts("1");
} else {
puts("0");
}
continue;
}
for (i = n - 1, pat = 0; i >= n / 2; i -= 2) {
if (prime[i] && prime[n - i]) {
pat++;
}
}
printf("%d\n", pat);
}
return 0;
}
|
[["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
| 0
| 250
|
#include <stdio.h>
int a[100000];
int main(void) {
int n;
int i, j, sum;
for (i = 2; i <= 50000; i++)
a[i] = 1;
for (i = 2; i * i <= 50000; i++) {
if (a[i] == 1) {
for (j = i * i; j * j <= 50000; j += i)
a[j] = 0;
}
}
// for (i = 0; i <= 100; i++)printf("a[%d]=%d\n", i, a[i]);
while (1) {
sum = 0;
scanf("%d", &n);
if (n == 0)
return (0);
for (i = 0; i <= 50000; i++) {
if (a[i] == 1 && n - i >= i && a[n - i] == 1) {
sum += 1;
// printf("%d %d\n", i, n - i);
}
}
printf("%d\n", sum);
}
}
|
#include <stdio.h>
int a[100000];
int main(void) {
int n;
int i, j, sum;
for (i = 2; i <= 50000; i++)
a[i] = 1;
for (i = 2; i * i <= 50000; i++) {
if (a[i] == 1) {
for (j = i * i; j <= 50000; j += i)
a[j] = 0;
}
}
// for (i = 0; i <= 100; i++)printf("a[%d]=%d\n", i, a[i]);
while (1) {
sum = 0;
scanf("%d", &n);
if (n == 0)
return (0);
for (i = 0; i <= 50000; i++) {
if (a[i] == 1 && n - i >= i && a[n - i] == 1) {
sum += 1;
// printf("%d %d\n", i, n - i);
}
}
printf("%d\n", sum);
}
}
|
[["-", 64, 9, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 64, 9, 0, 7, 15, 16, 31, 16, 12, 22]]
| 0
| 186
|
#include <stdio.h>
int main(void) {
int n, a, b;
int p[50001];
int ans;
for (int i = 0; i < 2; i++) {
p[i] = 0;
}
for (int i = 2; i <= 50000; i++) {
p[i] = 2;
}
for (int i = 2; i <= 50000; i++) {
if (p[i] != 0) {
p[i] = 1;
for (int j = i + 1; j <= 50000; j++) {
if (j % i == 0) {
p[j] = 0;
}
}
}
}
scanf("%d", &n);
while (n != 0) {
ans = 0;
a = 2;
b = n - a;
for (int i = 2; a < b; i++) {
if (p[a] == 1 && p[b] == 1) {
ans++;
}
a++;
b--;
}
printf("%d\n", ans);
scanf("%d", &n);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int n, a, b;
int p[50001];
int ans;
for (int i = 0; i < 2; i++) {
p[i] = 0;
}
for (int i = 2; i <= 50000; i++) {
p[i] = 2;
}
for (int i = 2; i <= 50000; i++) {
if (p[i] != 0) {
p[i] = 1;
for (int j = i + 1; j <= 50000; j++) {
if (j % i == 0) {
p[j] = 0;
}
}
}
}
scanf("%d", &n);
while (n != 0) {
ans = 0;
a = 2;
b = n - a;
for (int i = 2; a <= b; i++) {
if (p[a] == 1 && p[b] == 1) {
ans++;
}
a++;
b--;
}
printf("%d\n", ans);
scanf("%d", &n);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 0
| 238
|
#include <math.h>
#include <stdio.h>
#define SIZE 50000
char primes[SIZE];
int main() {
int i, j, sq, ne, n;
sq = sqrt(SIZE) + 1;
for (i = 1; i <= 25000; i++)
primes[i * 2 - 1] = 1;
for (i = 3; i < sq; i += 2) {
ne = SIZE / i + 1;
for (j = 2; j <= ne; j++) {
primes[j * i - 1] = 1;
}
}
do {
scanf("%d", &n);
if (n == 0)
break;
ne = n / 2;
for (i = 0, j = 0; i < ne; i++) {
if (primes[i] == 0 && primes[n - i - 2] == 0)
j++;
}
printf("%d\n", j);
} while (1);
return 0;
}
|
#include <math.h>
#include <stdio.h>
#define SIZE 50000
char primes[SIZE];
int main() {
int i, j, sq, ne, n;
sq = sqrt(SIZE) + 1;
for (i = 2; i <= 25000; i++)
primes[i * 2 - 1] = 1;
for (i = 3; i <= sq; i += 2) {
ne = SIZE / i + 1;
for (j = 2; j <= ne; j++) {
primes[j * i - 1] = 1;
}
}
do {
scanf("%d", &n);
if (n == 0)
break;
ne = n / 2;
for (i = 1, j = 0; i < ne; i++) {
if (primes[i] == 0 && primes[n - i - 2] == 0)
j++;
}
printf("%d\n", j);
} while (1);
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 10, 34, 31, 11, 12, 13], ["+", 8, 9, 0, 7, 10, 34, 31, 11, 12, 13]]
| 0
| 200
|
#include <math.h>
#include <stdio.h>
#define N 50000
int main() {
int i, j, n;
int prime[N];
for (i = 0; i < N; i++) {
prime[i] = 1;
}
prime[0] = 0;
for (i = 1; i < (int)sqrt(N); i++) {
if (prime[i] == 1) {
for (j = i + 1; (i + 1) * j <= N; j++) {
prime[(i + 1) * j - 1] = 0;
}
}
}
while (scanf("%d", &n)) {
if (n == 0)
break;
int cnt = 0;
for (i = 1; i < n; i++) {
if (i > n / 2)
break;
if (prime[i] == 1)
if (prime[n - (i + 2)] == 1)
cnt++;
}
printf("%d\n", cnt);
}
return 0;
}
|
#include <math.h>
#include <stdio.h>
#define N 50000
int main() {
int i, j, n;
int prime[N];
for (i = 0; i < N; i++) {
prime[i] = 1;
}
prime[0] = 0;
for (i = 1; i < (int)sqrt(N); i++) {
if (prime[i] == 1) {
for (j = i + 1; (i + 1) * j <= N; j++) {
prime[(i + 1) * j - 1] = 0;
}
}
}
while (scanf("%d", &n)) {
if (n == 0)
break;
int cnt = 0;
for (i = 1; i < n; i++) {
if (i >= n / 2)
break;
if (prime[i] == 1)
if (prime[n - (i + 2)] == 1)
cnt++;
}
printf("%d\n", cnt);
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
| 0
| 217
|
#include <iostream>
using namespace std;
bool isp[1 << 17];
int n;
main() {
isp[0] = isp[1] = 1;
for (int i = 2; i <= 5e4; i++) {
if (!isp[i]) {
for (int j = i + i; j <= 5e4; j += i)
isp[j] = 1;
}
}
while (cin >> n, n) {
int c = 0;
for (int i = 2; i + 2 <= n; i++)
if (!isp[i] && !isp[n - i])
c++;
cout << c << endl;
}
}
|
#include <iostream>
using namespace std;
bool isp[1 << 17];
int n;
main() {
isp[0] = isp[1] = 1;
for (int i = 2; i <= 5e4; i++) {
if (!isp[i]) {
for (int j = i + i; j <= 5e4; j += i)
isp[j] = 1;
}
}
while (cin >> n, n) {
int c = 0;
for (int i = 2; i <= n / 2; i++)
if (!isp[i] && !isp[n - i])
c++;
cout << c << endl;
}
}
|
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 85], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 140
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define sz(c) int((c).size())
vector<bool> primes(50100, true);
void build() {
primes[0] = false;
primes[1] = false;
for (int i = 2; 2 * i < sz(primes); i++) {
primes[2 * i] = false;
}
for (int i = 3; i * i <= sz(primes); i += 2) {
if (primes[i]) {
for (int j = 2; i * j < sz(primes); j++) {
primes[i * j] = false;
}
}
}
}
int gbc(int n) {
int res = 0;
if (primes[n - 2])
res++;
for (int i = 3; 2 * i <= n; i += 2) {
if (primes[n - i])
res++;
}
return res;
}
int main(int argc, char **argv) {
int n;
build();
while (cin >> n) {
if (!n)
break;
cout << gbc(n) << endl;
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define sz(c) int((c).size())
vector<bool> primes(50100, true);
void build() {
primes[0] = false;
primes[1] = false;
for (int i = 2; 2 * i < sz(primes); i++) {
primes[2 * i] = false;
}
for (int i = 3; i * i <= sz(primes); i += 2) {
if (primes[i]) {
for (int j = 2; i * j < sz(primes); j++) {
primes[i * j] = false;
}
}
}
}
int gbc(int n) {
int res = 0;
if (primes[n - 2])
res++;
for (int i = 3; 2 * i <= n; i += 2) {
if (primes[i] && primes[n - i])
res++;
}
return res;
}
int main(int argc, char **argv) {
int n;
build();
while (cin >> n) {
if (!n)
break;
cout << gbc(n) << endl;
}
return 0;
}
|
[["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70]]
| 1
| 253
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<bool> L(50000);
for (int i = 0; i < 50000; i++)
L[i] = true;
L[0] = L[1] = false;
for (int i = 2; i < 50000; i++) {
if (L[i]) {
for (int j = i * 2; j < 50000; j += i)
L[j] = false;
}
}
int n;
while (cin >> n && n) {
if (n % 2) {
cout << L[n - 2] << endl;
continue;
}
int cnt = 0;
for (int i = 3; i <= n / 2; i++) {
if (L[i] && L[n - i])
cnt++;
}
cout << cnt << endl;
}
}
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<bool> L(50000);
for (int i = 0; i < 50000; i++)
L[i] = true;
L[0] = L[1] = false;
for (int i = 2; i < 50000; i++) {
if (L[i]) {
for (int j = i * 2; j < 50000; j += i)
L[j] = false;
}
}
int n;
while (cin >> n && n) {
if (n % 2) {
cout << L[n - 2] << endl;
continue;
}
int cnt = 0;
for (int i = 2; i <= n / 2; i++) {
if (L[i] && L[n - i])
cnt++;
}
cout << cnt << endl;
}
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
| 1
| 185
|
#include <iostream>
using namespace std;
bool so[50000] = {};
int main() {
so[0] = 1;
so[1] = 1;
for (int i = 2; i * i < 50000; i++)
if (so[i] == 0)
for (int j = 2; j * i < 50000; j++)
so[i * j] = 1;
int n;
while (cin >> n && n) {
int co = 0;
for (int i = 2; i <= n / 2 + 1; i++)
if (so[i] == 0 && so[n - i] == 0)
co++;
cout << co << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
bool so[50001] = {};
int main() {
so[0] = 1;
so[1] = 1;
for (int i = 2; i * i <= 50000; i++)
if (so[i] == 0)
for (int j = 2; j * i <= 50000; j++)
so[i * j] = 1;
int n;
while (cin >> n && n) {
int co = 0;
for (int i = 2; i <= n / 2; i++)
if (so[i] == 0 && so[n - i] == 0)
co++;
cout << co << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 57, 64, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 57, 64, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 151
|
#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int prime[50000]; // i盤目の素数
bool is_prime[50001]; // is_prime[i]がtrueならiは素数
void sieve(int n) { // n以下の素数を返す
int p = 0;
for (int i = 0; i <= n; i++)
is_prime[i] = true;
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= n; i++) {
if (is_prime[i]) {
prime[p++] = i;
for (int j = 2 * i; j <= n; j += i)
is_prime[j] = false;
}
}
}
int main() {
int n;
sieve(50000);
while (1) {
cin >> n;
if (cin.eof())
break;
if (n % 2) {
o((is_prime[n - 2] ? 1 : 0));
continue;
}
int ans = 0;
rep(i, 2, n / 2 + 1) {
if (is_prime[i] && is_prime[n - i])
ans++;
}
o(ans);
}
}
|
#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int prime[50000]; // i盤目の素数
bool is_prime[50001]; // is_prime[i]がtrueならiは素数
void sieve(int n) { // n以下の素数を返す
int p = 0;
for (int i = 0; i <= n; i++)
is_prime[i] = true;
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= n; i++) {
if (is_prime[i]) {
prime[p++] = i;
for (int j = 2 * i; j <= n; j += i)
is_prime[j] = false;
}
}
}
int main() {
int n;
sieve(50000);
while (1) {
cin >> n;
if (n == 0)
break;
if (n % 2) {
o((is_prime[n - 2] ? 1 : 0));
continue;
}
int ans = 0;
rep(i, 2, n / 2 + 1) {
if (is_prime[i] && is_prime[n - i])
ans++;
}
o(ans);
}
}
|
[["-", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 306
|
#include <cmath>
#include <iostream>
using namespace std;
int x[100000], y[100000], n, sum;
int main() {
for (int i = 2; i < 100000; i++) {
for (int j = 2; j <= sqrt(i); j++) {
if (i % j == 0) {
goto E;
}
}
x[i] = 1;
E:;
}
while (true) {
cin >> n;
sum = 0;
if (!n) {
break;
}
for (int i = 2; i < n; i++) {
if (x[i] == 1 && x[n - i] == 1) {
sum++;
}
}
cout << sum << endl;
}
}
|
#include <cmath>
#include <iostream>
using namespace std;
int x[100000], y[100000], n, sum;
int main() {
for (int i = 2; i < 100000; i++) {
for (int j = 2; j <= sqrt(i); j++) {
if (i % j == 0) {
goto E;
}
}
x[i] = 1;
E:;
}
while (true) {
cin >> n;
sum = 0;
if (!n) {
break;
}
for (int i = 2; i <= n / 2; i++) {
if (x[i] == 1 && x[n - i] == 1) {
sum++;
}
}
cout << sum << endl;
}
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 85], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 155
|
#include <iostream>
using namespace std;
bool flag[50001];
int prime[50001];
int main() {
int n = 0;
int i, j;
flag[0] = flag[1] = true;
for (i = 2; i * i <= 50000; i++) {
if (flag[i] != true) {
for (j = i * i; j <= 50000; j += i) {
flag[j] = true;
}
}
}
j = 0;
for (i = 0; i <= 50000; i++) {
if (!flag[i]) {
prime[j++] = i;
}
}
while (cin >> n) {
int cnt = 0;
for (i = 0; prime[i] <= n / 2; i++) {
if (flag[n - prime[i]] == false) {
cnt++;
}
}
cout << cnt << endl;
}
return (0);
}
|
#include <iostream>
using namespace std;
bool flag[50001];
int prime[50001];
int main() {
int n = 0;
int i, j;
flag[0] = flag[1] = true;
for (i = 2; i * i <= 50000; i++) {
if (flag[i] != true) {
for (j = i * i; j <= 50000; j += i) {
flag[j] = true;
}
}
}
j = 0;
for (i = 0; i <= 50000; i++) {
if (!flag[i]) {
prime[j++] = i;
}
}
while (cin >> n, n) {
int cnt = 0;
for (i = 0; prime[i] <= n / 2; i++) {
if (flag[n - prime[i]] == false) {
cnt++;
}
}
cout << cnt << endl;
}
return (0);
}
|
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
| 1
| 199
|
#include <bits/stdc++.h>
using namespace std;
vector<int> p(0);
void Prime(int n) {
bool flg[50000];
int indx = 2;
flg[0] = flg[1] = 0;
for (int i = 0; i < n; i++)
flg[i] = 0;
while (indx < n) {
flg[indx] = 1;
p.push_back(indx);
for (int i = 2; i * indx < n; i++) {
flg[indx * i] = 1;
}
while (flg[indx] == 1 && indx < n)
indx++;
}
}
int main() {
int n;
int sum;
Prime(50000);
while (cin >> n, n) {
sum = 0;
// if(n%2==0){
for (int i = 0; i < (int)p.size(); i++) {
if (p[i] >= n)
break;
if (binary_search(p.begin(), p.end(), n - p[i]) == true)
sum++;
}
// }
cout << sum << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> p(0);
void Prime(int n) {
bool flg[50000];
int indx = 2;
flg[0] = flg[1] = 0;
for (int i = 0; i < n; i++)
flg[i] = 0;
while (indx < n) {
flg[indx] = 1;
p.push_back(indx);
for (int i = 2; i * indx < n; i++) {
flg[indx * i] = 1;
}
while (flg[indx] == 1 && indx < n)
indx++;
}
}
int main() {
int n;
int sum;
Prime(50000);
while (cin >> n, n) {
sum = 0;
for (int i = 0; i < (int)p.size(); i++) {
if (p[i] >= n)
break;
if (binary_search(p.begin() + i, p.end(), n - p[i]) == true)
sum++;
}
cout << sum << endl;
}
return 0;
}
|
[["+", 51, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 12, 22]]
| 1
| 237
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool a[60000]{};
int main() {
for (int b = 2; b < 60000; b++) {
if (!(a[b])) {
for (int c = b * 2; c <= 150000; c += b)
a[c] = true;
}
}
int e;
while (cin >> e, e) {
int s = 0;
for (int f = 2; f <= e / 2; f++) {
if (!a[f] && !a[e - f])
s++;
}
cout << s << endl;
}
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool a[60000]{};
int main() {
for (int b = 2; b < 60000; b++) {
if (!(a[b])) {
for (int c = b * 2; c < 60000; c += b)
a[c] = true;
}
}
int e;
while (cin >> e, e) {
int s = 0;
for (int f = 2; f <= e / 2; f++) {
if (!a[f] && !a[e - f])
s++;
}
cout << s << endl;
}
}
|
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 141
|
#include <iostream>
using namespace std;
int main() {
bool p[100000];
p[0] = p[1] = false;
for (int i = 2; i < 100000; i++) {
p[i] = true;
}
for (int i = 2; i * i < 100000; i++) {
if (p[i])
for (int j = i * i; j < 100000; j += i) {
p[j] = false;
}
}
while (1) {
int count = 0;
int N;
cin >> N;
if (N == 0)
break;
for (int i = 2; i < N / 2; i++) {
if (p[i] && p[N - i])
count++;
}
cout << count << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
bool p[100000];
p[0] = p[1] = false;
for (int i = 2; i < 100000; i++) {
p[i] = true;
}
for (int i = 2; i * i < 100000; i++) {
if (p[i])
for (int j = i * i; j < 100000; j += i) {
p[j] = false;
}
}
while (1) {
int count = 0;
int N;
cin >> N;
if (N == 0)
break;
for (int i = 2; i < (N / 2) + 1; i++) {
if (p[i] && p[N - i])
count++;
}
cout << count << endl;
}
return 0;
}
|
[["+", 0, 7, 15, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 7, 15, 16, 12, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 174
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[50000];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 50000; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 50000; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 50000; j += i) {
is_prime[j] = false;
}
}
}
while (true) {
int n;
cin >> n;
if (n == 0)
break;
int cnt = 0;
for (int i = 1; i <= n / 2; i = i + 2) {
if (is_prime[i] && is_prime[n - i]) {
cnt++;
}
}
cout << cnt << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[50000];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 50000; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 50000; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 50000; j += i) {
is_prime[j] = false;
}
}
}
while (true) {
int n;
cin >> n;
if (n == 0)
break;
int cnt = 0;
for (int i = 2; i <= n / 2; i++) {
if (is_prime[i] && is_prime[n - i]) {
cnt++;
}
}
cout << cnt << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 26, 11, 17, 32], ["-", 8, 9, 0, 7, 26, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 26, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 26, 11, 12, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29]]
| 1
| 181
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[50000];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 50000; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 50000; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 50000; j += i) {
is_prime[j] = false;
}
}
}
while (true) {
int n;
cin >> n;
int count = 0;
if (cin.eof())
break;
for (int i = 2; i <= (n / 2); i++) {
if (is_prime[i] && is_prime[n - i]) {
count++;
}
}
cout << count << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[50000];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 50000; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 50000; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 50000; j += i) {
is_prime[j] = false;
}
}
}
while (true) {
int n;
cin >> n;
int count = 0;
if (n == 0)
break;
for (int i = 2; i <= (n / 2); i++) {
if (is_prime[i] && is_prime[n - i]) {
count++;
}
}
cout << count << endl;
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 182
|
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
#define PII pair<int, int>
#define VS vector<string>
#define VI vector<int>
#define ll long long int
#define debug(x) cout << x << " :" << #x << endl
int main(void) {
int n;
vector<bool> p;
int count = 0;
while (1) {
count = 0;
cin >> n;
if (n == 0)
break;
if (n % 2 || n < 4) {
cout << 0 << endl;
continue;
}
p = vector<bool>(n, true);
p[0] = false;
int i = 3;
while (i <= n) {
p[i] = false;
i += 2;
}
i = 2;
while (i <= n) {
if (p[i]) {
int j = 2 * (i + 1) - 1;
while (j <= n) {
p[j] = false;
j += i + 1;
}
}
i += 2;
}
if (p[1] && p[n - 3])
count++;
i = 2;
while (i <= n / 2) {
if (p[i] && p[n - i - 2]) {
count++;
}
i += 2;
}
cout << count << endl;
p.clear();
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
#define PII pair<int, int>
#define VS vector<string>
#define VI vector<int>
#define ll long long int
#define debug(x) cout << x << " :" << #x << endl
int main(void) {
int n;
vector<bool> p;
int count = 0;
while (1) {
count = 0;
cin >> n;
if (n == 0)
break;
if (n < 4) {
cout << 0 << endl;
continue;
}
p = vector<bool>(n, true);
p[0] = false;
int i = 3;
while (i <= n) {
p[i] = false;
i += 2;
}
i = 2;
while (i <= n) {
if (p[i]) {
int j = 2 * (i + 1) - 1;
while (j <= n) {
p[j] = false;
j += i + 1;
}
}
i += 2;
}
if (p[1] && p[n - 3])
count++;
i = 2;
while (i < n / 2) {
if (p[i] && p[n - i - 2]) {
count++;
}
i += 2;
}
cout << count << endl;
p.clear();
}
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 109], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18]]
| 1
| 296
|
#include <stdio.h>
#define max 50010
int main(void) {
long long i, j, k, n;
bool prime[max];
for (i = 0; i < max; ++i)
prime[i] = true;
prime[0] = prime[1] = false;
for (i = 2; i < 250; ++i)
if (prime[i])
for (j = 2; i * j < max; ++j)
prime[i * j] = false;
while (1) {
int ans = 0;
scanf("%lld", &n);
if (!n)
break;
for (i = 3; i <= n / 2; ++i)
if (prime[i] && prime[n - i])
++ans;
printf("%d\n", ans);
}
return 0;
}
|
#include <stdio.h>
#define max 50010
int main(void) {
long long i, j, k, n;
bool prime[max];
for (i = 0; i < max; ++i)
prime[i] = true;
prime[0] = prime[1] = false;
for (i = 2; i < 250; ++i)
if (prime[i])
for (j = 2; i * j < max; ++j)
prime[i * j] = false;
while (1) {
int ans = 0;
scanf("%lld", &n);
if (!n)
break;
for (i = 2; i <= n / 2; ++i)
if (prime[i] && prime[n - i])
++ans;
printf("%d\n", ans);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13]]
| 1
| 177
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[50001];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 50001; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 50001; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 50001; j = j + i) {
is_prime[j] = false;
}
}
}
while (true) {
int n;
cin >> n;
int cnt = 0;
for (int i = 3; i <= n / 2; i = i + 2) {
if (is_prime[i] && is_prime[n - i]) {
cnt++;
}
}
if (n == 0)
break;
cout << cnt << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[50001];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 50001; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 50001; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 50001; j = j + i) {
is_prime[j] = false;
}
}
}
while (true) {
int n;
cin >> n;
int cnt = 0;
for (int i = 2; i <= n / 2; i++) {
if (is_prime[i] && is_prime[n - i]) {
cnt++;
}
}
if (n == 0)
break;
cout << cnt << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 26, 11, 17, 32], ["-", 8, 9, 0, 7, 26, 11, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 26, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 26, 11, 12, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29]]
| 1
| 183
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[1000000];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 1000000; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 1000000; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 1000000; j += i) {
is_prime[j] = false;
}
}
}
while (1) {
int n, count;
cin >> n;
if (cin.eof())
break;
while (1) {
count = 0;
for (int i = 0; i <= n / 2; i++) {
if (is_prime[i] && is_prime[n - i])
count++;
}
cout << count << endl;
break;
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
bool is_prime[1000000];
is_prime[0] = is_prime[1] = false;
for (int i = 2; i < 1000000; i++) {
is_prime[i] = true;
}
for (int i = 2; i * i < 1000000; i++) {
if (is_prime[i]) {
for (int j = i * i; j < 1000000; j += i) {
is_prime[j] = false;
}
}
}
while (1) {
int n, count;
cin >> n;
if (n == 0)
break;
while (1) {
count = 0;
for (int i = 0; i <= n / 2; i++) {
if (is_prime[i] && is_prime[n - i])
count++;
}
cout << count << endl;
break;
}
}
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 2, 63, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 17, 131], ["-", 0, 57, 15, 339, 51, 2, 63, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 24], ["-", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 187
|
#include <cstdio>
#include <cstring>
#define N 50
using namespace std;
int main(void) {
int p[N + 1] = {0};
int n, ans;
for (int i = 2; i < N; i++) {
if (p[i] == -1)
continue;
p[i] = 1;
for (int j = i * 2; j < N; j += i) {
p[j] = -1;
}
}
while (scanf("%d", &n), n) {
ans = 0;
for (int i = 2; i <= n / 2; i++) {
if (p[i] == 1 && p[n - i] == 1) {
ans++;
}
}
printf("%d\n", ans);
}
return 0;
}
|
#include <cstdio>
#include <cstring>
#define N 50000
using namespace std;
int main(void) {
int p[N + 1] = {0};
int n, ans;
for (int i = 2; i < N; i++) {
if (p[i] == -1)
continue;
p[i] = 1;
for (int j = i * 2; j < N; j += i) {
p[j] = -1;
}
}
while (scanf("%d", &n), n) {
ans = 0;
for (int i = 2; i <= n / 2; i++) {
if (p[i] == 1 && p[n - i] == 1) {
ans++;
}
}
printf("%d\n", ans);
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
| 1
| 169
|
#include <stdio.h>
int main(void) {
int a, b, n;
int i;
int ans;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
ans = 0;
a %= b;
for (i = 0; i < n; i++) {
ans = a * 10 / b;
a = a * 10 % b;
}
printf("%d\n", ans);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b, n;
int i;
int ans;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
ans = 0;
a %= b;
for (i = 0; i < n; i++) {
ans += a * 10 / b;
a = a * 10 % b;
}
printf("%d\n", ans);
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107]]
| 0
| 96
|
#include <stdio.h>
int main() {
int i;
int a, b, n, sum;
while (scanf("%d%d%d", &a, &b, &n) != -1) {
a %= b;
sum = 0;
for (i = 0; i < n; i++) {
sum += a * 10 / b;
a = a * 10 / b;
}
printf("%d\n", sum);
}
return 0;
}
|
#include <stdio.h>
int main() {
int i;
int a, b, n, sum;
while (scanf("%d%d%d", &a, &b, &n) != -1) {
a %= b;
sum = 0;
for (i = 0; i < n; i++) {
sum += a * 10 / b;
a = a * 10 % b;
}
printf("%d\n", sum);
}
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109]]
| 0
| 94
|
#include <stdio.h>
#include <string.h>
int main(void) {
int i, j, n, a, b, sum;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
sum = 0;
a %= b;
while (n--) {
a *= 10;
sum += a / b;
a %= b;
printf("a");
}
printf("%d\n", sum);
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
int main(void) {
int i, j, n, a, b, sum;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
sum = 0;
a %= b;
while (n--) {
a *= 10;
sum += a / b;
a %= b;
}
printf("%d\n", sum);
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 0
| 95
|
#include <stdio.h>
int main() {
int a, b, n;
int x, i;
int sum;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
sum = 0;
if (a > b)
a = a % b;
for (i = 0; i < n; i++) {
a = a * 10;
sum += a / b;
a = a % b;
if (a == 0)
break;
}
printf("%d\n", sum);
}
return 0;
}
|
#include <stdio.h>
int main() {
int a, b, n;
int x, i;
int sum;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
sum = 0;
a = a % b;
for (i = 0; i < n; i++) {
a = a * 10;
sum += a / b;
a = a % b;
if (a == 0)
break;
}
printf("%d\n", sum);
}
return 0;
}
|
[["-", 8, 9, 0, 52, 8, 9, 0, 57, 0, 121], ["-", 0, 52, 8, 9, 0, 57, 15, 23, 0, 24], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["-", 0, 52, 8, 9, 0, 57, 15, 23, 0, 25]]
| 0
| 115
|
#include <iostream>
using namespace std;
long a, b, n, s;
main() {
while (cin >> a >> b >> n) {
s = 0;
for (; n--; a = a * 10 % b)
s += a * 10 / b;
cout << s << endl;
}
}
|
#include <iostream>
using namespace std;
long a, b, n, s;
main() {
while (cin >> a >> b >> n) {
a %= b;
s = 0;
for (; n--; a = a * 10 % b)
s += a * 10 / b;
cout << s << endl;
}
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 64
|
#include <cstdio>
#include <iostream>
using namespace std;
#define rep2(x, from, to) for (int x = (from); x < (to); ++(x))
#define rep(x, to) rep2(x, 0, to)
int main() {
int a, b, n;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
int r = 0;
a = a % b;
a *= 10;
rep(i, n) {
rep(j, 10) {
if (b * j > a) {
r += j - 1;
a -= b * (j - 1);
break;
}
}
a *= 10;
}
cout << r << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
#define rep2(x, from, to) for (int x = (from); x < (to); ++(x))
#define rep(x, to) rep2(x, 0, to)
int main() {
int a, b, n;
while (scanf("%d %d %d", &a, &b, &n) != EOF) {
int r = 0;
a = a % b;
a *= 10;
rep(i, n) {
rep(j, 11) {
if (b * j > a) {
r += j - 1;
a -= b * (j - 1);
break;
}
}
a *= 10;
}
cout << r << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 42, 0, 2, 3, 4, 0, 13]]
| 1
| 133
|
#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
int a, b;
int n;
while (cin >> a >> b >> n) {
int s = 0;
if (a >= b)
a /= b;
rep(i, 1, n + 1) {
a *= 10;
// o(a);
if (a / b == 0)
continue;
else {
s += a / b;
a %= b;
}
}
o(s);
}
}
|
#include <bits/stdc++.h>
#define rep(i, l, n) for (int i = l; i < n; i++)
#define rer(i, l, n) for (int i = l; i <= n; i++)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define pb(a) push_back(a)
#define mk(a, b) make_pair(a, b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
int main() {
int a, b;
int n;
while (cin >> a >> b >> n) {
int s = 0;
if (a >= b) {
a %= b;
}
rep(i, 1, n + 1) {
a *= 10;
// o(" "<<a);
if (a / b == 0)
continue;
else {
s += a / b;
a %= b;
}
}
o(s);
}
}
|
[["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 90], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
| 1
| 173
|
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int n, s, a, b;
while (cin >> a >> b >> n) {
s = 0;
for (int i = 1; i <= n; i++) {
a *= 10;
s += a / b;
a %= b;
}
cout << s << endl;
}
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int n, s, a, b;
while (cin >> a >> b >> n) {
s = 0;
a %= b;
for (int i = 1; i <= n; i++) {
a *= 10;
s += a / b;
a %= b;
}
cout << s << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 78
|
#include <iostream>
using namespace std;
int main() {
int a, b, n;
while (cin >> a >> b >> n) {
int sum = 0;
a %= 10;
for (int i = 0; i < n; ++i) {
a *= 10;
sum += (a / b) % 10;
a %= b;
}
cout << sum << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, n;
while (cin >> a >> b >> n) {
int sum = 0;
a %= b;
for (int i = 0; i < n; ++i) {
a *= 10;
sum += (a / b) % 10;
a %= b;
}
cout << sum << endl;
}
}
|
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]]
| 1
| 80
|
#include <iostream>
using namespace std;
int main() {
int a, b, n;
while (cin >> a >> b >> n) {
if (a > b)
a %= b;
int sum = 0;
for (int i = 0; i < n; i++) {
a *= 10;
sum += a / b;
a %= b;
}
cout << sum << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, n;
while (cin >> a >> b >> n) {
if (a >= b)
a %= b;
int sum = 0;
for (int i = 0; i < n; i++) {
a *= 10;
sum += a / b;
a %= b;
}
cout << sum << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
| 1
| 85
|
#!ruby -alp
a,b,n=$F.map &:hex
$_=0
n.times{a=a%b*10
$_+=a/b}
|
#!ruby -alp
a,b,n=$F.map &:to_i
$_=0
n.times{a=a%b*10
$_+=a/b}
|
[["-", 0, 662, 12, 652, 3, 4, 0, 752, 0, 753], ["+", 0, 662, 12, 652, 3, 4, 0, 752, 0, 753]]
| 4
| 32
|
while True:
try:
a, b, n = map(int, input().split())
except:
break
s = str(a/b)
sum = 0
x = s.index(".")+1
for i in s[x:2+x]:
sum += int(i)
print(sum)
|
while True:
try:
a, b, n = map(int, input().split())
except:
break
s = str(a/b)
sum = 0
x = s.index(".")+1
for i in s[x:x+n]:
sum += int(i)
print(sum)
|
[["-", 0, 7, 12, 206, 206, 663, 0, 657, 31, 612], ["-", 0, 7, 12, 206, 206, 663, 0, 657, 17, 72], ["+", 0, 7, 12, 206, 206, 663, 0, 657, 17, 72], ["+", 0, 7, 12, 206, 206, 663, 0, 657, 12, 22]]
| 5
| 71
|
import re
while True:
try:
a,b,n = map(int, input().strip().split())
u = '%.100f' % (float(a)/b)
v = list(re.sub(r'[^\.]*\.', '', u))[:n]
w = sum(map(int,v))
print(w)
except EOFError:
break
|
import re
while True:
try:
a,b,n = map(int, input().strip().split())
u = str((float(a)/b))
v = list(re.sub(r'[^\.]*\.', '', u))[:n]
w = sum(map(int,v))
print(w)
except EOFError:
break
|
[["-", 0, 1, 0, 662, 12, 657, 31, 557, 0, 654], ["-", 0, 1, 0, 662, 12, 657, 31, 557, 0, 6], ["-", 0, 1, 0, 662, 12, 657, 31, 557, 0, 655], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 109], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 23, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 23, 0, 25]]
| 5
| 84
|
import sys
for a, b, n in (map(int, l.split()) for l in sys.stdin.readlines()):
if a >= b:
a -= b
a *= 10
ans = 0
for _ in [0]*n:
d, m = divmod(a, b)
ans += d
a = m*10
print(ans)
|
import sys
for a, b, n in (map(int, l.split()) for l in sys.stdin.readlines()):
if a >= b:
a %= b
a *= 10
ans = 0
for _ in [0]*n:
d, m = divmod(a, b)
ans += d
a = m*10
print(ans)
|
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 132]]
| 5
| 77
|
#include <stdio.h>
int main(void) {
char card[11];
int a, b, c, below;
int i;
double percent;
while (scanf("%d%d%d", &a, &b, &c) != EOF) {
for (i = 1; i <= 10; i++) {
card[i] = 0;
}
card[a] = card[b] = card[c] = 0;
below = 0;
for (i = 1; i <= 10; i++) {
if (card[i] == 0 && a + b + i <= 20) {
below++;
}
}
percent = below / 7 * 100.0;
if (percent >= 50.0) {
printf("YES\n");
}
else {
printf("NO\n");
}
}
return (0);
}
|
#include <stdio.h>
int main(void) {
char card[11];
int a, b, c, below;
int i;
double percent;
while (scanf("%d%d%d", &a, &b, &c) != EOF) {
for (i = 1; i <= 10; i++) {
card[i] = 0;
}
card[a] = card[b] = card[c] = 1;
below = 0;
for (i = 1; i <= 10; i++) {
if (card[i] == 0 && a + b + i <= 20) {
below++;
}
}
percent = (below / 7.0) * 100.0;
if (percent >= 50.0) {
printf("YES\n");
}
else {
printf("NO\n");
}
}
return (0);
}
|
[["-", 0, 1, 0, 11, 12, 11, 12, 11, 12, 13], ["+", 0, 1, 0, 11, 12, 11, 12, 11, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]]
| 0
| 172
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>
using namespace std;
int main() {
int a, b, c, p, sum;
while (scanf("%d %d %d", &a, &b, &c) != EOF) {
sum = a + b;
p = 0;
for (int i = 1; i <= 10; i++) {
if (i != a && i != b && i != c) {
if (sum + i <= 20) {
p++;
}
}
}
if (p >= 0.35)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>
using namespace std;
int main() {
int a, b, c, p, sum;
while (scanf("%d %d %d", &a, &b, &c) != EOF) {
sum = a + b;
p = 0;
for (int i = 1; i <= 10; i++) {
if (i != a && i != b && i != c) {
if (sum + i <= 20) {
p++;
}
}
}
if (p >= 3.5)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 140
|
#include <iostream>
#include <string>
using namespace std;
string solve(int c1, int c2, int c3) {
int bunbo = 7; // not 6
int mysum = c1 + c2;
int okCount = 0;
double kakuritu;
for (int i = 1; i <= 10; i++) {
if (i == c1 || i == c2 || i == c3)
continue;
else {
if (mysum + i <= 20)
okCount++;
}
}
kakuritu = (double)okCount / mysum * 100.0;
if (kakuritu >= 50.0)
return "YES";
else
return "NO";
}
int main() {
int c1, c2, c3;
while (cin >> c1 >> c2 >> c3, !cin.eof()) {
cout << solve(c1, c2, c3) << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
string solve(int c1, int c2, int c3) {
int bunbo = 7; // not 6. if6 -> (in)8 9 10 (out)YES.
int mysum = c1 + c2;
int okCount = 0;
double kakuritu;
for (int i = 1; i <= 10; i++) {
if (i == c1 || i == c2 || i == c3)
continue;
else {
if (mysum + i <= 20)
okCount++;
}
}
kakuritu = (double)okCount / bunbo * 100.0;
if (kakuritu >= 50.0)
return "YES";
else
return "NO";
}
int main() {
int c1, c2, c3;
while (cin >> c1 >> c2 >> c3, !cin.eof()) {
cout << solve(c1, c2, c3) << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22]]
| 1
| 165
|
#include <iostream>
using namespace std;
int main() {
int c[3];
while (cin >> c[0]) {
for (int i = 1; i < 3; i++)
cin >> c[i];
int s = 0;
double p = 0;
for (int i = 1; i <= 10; i++) {
if (i != c[0] || i != c[1] || i != c[2]) {
if (i + c[1] + c[2] <= 20)
s++;
}
}
p = s * 100 / 7;
if (p >= 50)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int c[3];
while (cin >> c[0]) {
for (int i = 1; i < 3; i++)
cin >> c[i];
int s = 0;
double p = 0;
for (int i = 1; i <= 10; i++) {
if (i != c[0] || i != c[1] || i != c[2]) {
if (i + c[0] + c[1] <= 20)
s++;
}
}
// cout<<s<<endl;
p = s * 100 / 7;
// cout<<p<<endl;
if (p >= 50)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["+", 31, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 13]]
| 1
| 151
|
#include <cstdio>
using namespace std;
int main() {
int c[3];
int cnt;
int i;
while (scanf("%d %d %d", &c[0], &c[1], &c[2]) != EOF) {
cnt = 0;
for (i = 1; i <= 10; i++) {
if (i != c[0] && i != c[1] && i != c[2]) {
if (c[0] + c[1] + c[2] + i <= 20) {
cnt++;
}
}
}
if (cnt > 3) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return (0);
}
|
#include <cstdio>
using namespace std;
int main() {
int c[3];
int cnt;
int i;
while (scanf("%d %d %d", &c[0], &c[1], &c[2]) != EOF) {
cnt = 0;
for (i = 1; i <= 10; i++) {
if (i != c[0] && i != c[1] && i != c[2]) {
if (c[0] + c[1] + i <= 20) {
cnt++;
}
}
}
if (cnt > 3) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return (0);
}
|
[["-", 51, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 73], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72]]
| 1
| 157
|
#include <fstream>
int main() {
int C1, C2, C3, counter;
while (scanf("%d %d %d", &C1, &C2, &C3) != EOF) {
counter = 0;
for (int i = 1; i < 11; i++) {
if ((i != C1 && i != C2 && i != C3) && (C1 + C2 + i <= 20)) {
counter++;
}
}
if (counter < 4) {
printf("No\n");
} else {
printf("Yes\n");
}
}
return 0;
}
|
#include <fstream>
int main() {
int C1, C2, C3, counter;
while (scanf("%d %d %d", &C1, &C2, &C3) != EOF) {
counter = 0;
for (int i = 1; i < 11; i++) {
if ((i != C1 && i != C2 && i != C3) && (C1 + C2 + i <= 20)) {
counter++;
}
}
if (counter < 4) {
printf("NO\n");
} else {
printf("YES\n");
}
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 120
|
#include <algorithm>
#include <cctype>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int c1, c2, c3;
while (cin >> c1 >> c2 >> c3) {
bool arr[10] = {false};
int sum = c1 + c2;
arr[c1 - 1] = true;
arr[c2 - 1] = true;
arr[c3 - 1] = true;
int count = 0;
int count2 = 0;
for (int i = 0; i < 10; i++) {
if ((!arr[i]) && ((sum + i + 1) < 20))
count++;
}
double rate = 1.0 * count * 6 / 56;
if (rate > 0.5)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
// while(1);
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int c1, c2, c3;
while (cin >> c1 >> c2 >> c3) {
bool arr[10] = {false};
int sum = c1 + c2;
arr[c1 - 1] = true;
arr[c2 - 1] = true;
arr[c3 - 1] = true;
int count = 0;
int count2 = 0;
for (int i = 0; i < 10; i++) {
if ((!arr[i]) && ((sum + i + 1) <= 20)) {
count++;
}
}
double rate = 1.0 * count * 6 / 42;
if (rate > 0.5)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
// while(1);
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 23, 0, 16, 17, 18], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 19], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
| 1
| 196
|
#include <cstdio>
int main() {
int c1, c2, c3;
bool mem[11];
while (scanf("%d%d%d", &c1, &c2, &c3) != EOF) {
for (int i = 0; i < 11; i++)
mem[i] = false;
mem[c1] = mem[c2] = mem[c3] = true;
int ok = 0;
for (int i = 1; i <= 10; i++) {
if (!mem[i] && c1 + c2 + i <= 20) {
ok++;
}
}
printf("%s\n", ok >= 4 ? "Yes" : "No");
}
return 0;
}
|
#include <cstdio>
int main() {
int c1, c2, c3;
bool mem[11];
while (scanf("%d%d%d", &c1, &c2, &c3) != EOF) {
for (int i = 0; i < 11; i++)
mem[i] = false;
mem[c1] = mem[c2] = mem[c3] = true;
int ok = 0;
for (int i = 1; i <= 10; i++) {
if (!mem[i] && c1 + c2 + i <= 20) {
ok++;
}
}
printf("%s\n", ok >= 4 ? "YES" : "NO");
}
return 0;
}
|
[["-", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["-", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6]]
| 1
| 146
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int c1, c2, c3, cnt = 0;
while (cin >> c1 >> c2 >> c3) {
cnt = 0;
for (int i = 0; i < 10; i++) {
if (i != c1 && i != c2 && i != c3 && i + c1 + c2 < 21)
cnt++;
}
if (cnt > 3)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
int c1, c2, c3, cnt = 0;
while (cin >> c1 >> c2 >> c3) {
cnt = 0;
for (int i = 1; i <= 10; i++) {
if (i != c1 && i != c2 && i != c3 && i + c1 + c2 < 21)
cnt++;
}
if (cnt > 3)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 115
|
#include <cstdio>
using namespace std;
int main() {
int a, b, c;
while (scanf("%d%d%d", &a, &b, &c) == 3) {
int t[11] = {};
t[a] = t[b] = t[c] = 1;
int u = 0;
for (int i = 1; i <= 10; ++i) {
if (!t[i] && a + b + i <= 20) {
++u;
}
}
puts(u > 3 ? "Yes" : "No");
}
}
|
#include <cstdio>
using namespace std;
int main() {
int a, b, c;
while (scanf("%d%d%d", &a, &b, &c) == 3) {
int t[11] = {};
t[a] = t[b] = t[c] = 1;
int u = 0;
for (int i = 1; i <= 10; ++i) {
if (!t[i] && a + b + i <= 20) {
++u;
}
}
puts(u > 3 ? "YES" : "NO");
}
}
|
[["-", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 6], ["-", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 6]]
| 1
| 124
|
#include <iostream>
#include <string>
using namespace std;
int main() {
long a, b, c, i, j[11], k;
while (cin >> a) {
cin >> b >> c;
for (i = 1; i <= 10; i++)
j[i] = 0;
j[a] = j[b] = j[c] = 1;
for (k = 0, i = 1; i <= 10; i++) {
k += j[i];
if (k == 4)
break;
}
if (a + b + i <= 20)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
long a, b, c, i, j[11], k;
while (cin >> a) {
cin >> b >> c;
for (i = 1; i <= 10; i++)
j[i] = 1;
j[a] = j[b] = j[c] = 0;
for (k = 0, i = 1; i <= 10; i++) {
k += j[i];
if (k == 4)
break;
}
if (a + b + i <= 20)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["-", 0, 1, 0, 11, 12, 11, 12, 11, 12, 13], ["+", 0, 1, 0, 11, 12, 11, 12, 11, 12, 13]]
| 1
| 145
|
cards = Array.new(11,1)
a,b,c = gets.split.map &:to_i
cards[a] = 0
cards[b] = 0
cards[c] = 0
r = 20 - a - b
count = 0
r = 10 if r > 10
r.times { |i|
count += cards[i + 1]
}
puts ["NO", "YES"][count/4]
|
while t = gets
cards = Array.new(11,1)
a,b,c = t.split.map &:to_i
cards[a] = 0
cards[b] = 0
cards[c] = 0
r = 20 - a - b
count = 0
r = 10 if r > 10
r.times { |i|
count += cards[i + 1]
}
puts ["NO", "YES"][count/4]
end
|
[["+", 36, 36, 36, 36, 0, 493, 0, 89, 0, 89], ["+", 36, 36, 0, 493, 0, 89, 15, 662, 31, 22], ["+", 36, 36, 0, 493, 0, 89, 15, 662, 0, 32], ["+", 36, 36, 0, 493, 0, 89, 15, 662, 12, 22], ["-", 0, 493, 0, 662, 12, 652, 486, 652, 486, 22], ["+", 8, 170, 0, 662, 12, 652, 486, 652, 486, 22], ["+", 36, 36, 0, 493, 0, 89, 8, 170, 0, 444]]
| 4
| 89
|
while l = gets do
c1,c2,c3 = l.split.map(&:to_i)
cards = (1..10).to_a
cards.delete(c1)
cards.delete(c2)
cards.delete(c3)
p cards
rest = 20-(c1+c2)
puts cards.select{|x| x>rest}.size > 3 ? "NO" : "YES"
end
|
while l = gets do
c1,c2,c3 = l.split.map(&:to_i)
cards = (1..10).to_a
cards.delete(c1)
cards.delete(c2)
cards.delete(c3)
rest = 20-(c1+c2)
puts cards.select{|x| x>rest}.size > 3 ? "NO" : "YES"
end
|
[["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["-", 0, 89, 8, 170, 0, 652, 3, 4, 0, 22]]
| 4
| 83
|
while True:
try:
a, b, c = map(int, input().split())
except:
break
l=[True] * 11
l[a] = l[b] = l[c] = False
sum = a + b
over = 0
for i in range(1,11):
if l[i]:
if sum + i > 20:
print(i)
over += 1
if over / 7 <= 0.5:
print("YES")
else:
print("NO")
|
while True:
try:
a, b, c = map(int, input().split())
except:
break
l=[True] * 11
l[a] = l[b] = l[c] = False
sum = a + b
over = 0
for i in range(1,11):
if l[i]:
if sum + i > 20:
over += 1
if over / 7 < 0.5:
print("YES")
else:
print("NO")
|
[["-", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18]]
| 5
| 108
|
while 1:
a=[i+1 for i in range(10)]
try:b=list(map(int,input().split()))
except:break
for i in b:a.remove(b)
print('YES' if sum([1 for i in a if i<=20-sum(b[:2])])/7>=0.5 else 'NO')
|
while 1:
a=[i+1 for i in range(10)]
try:b=list(map(int,input().split()))
except:break
for i in b:a.remove(i)
print('YES' if sum([1 for i in a if i<=20-sum(b[:2])])/7>=0.5 else 'NO')
|
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
| 5
| 88
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while ((line = br.readLine()) != null) {
double ax, ay, bx, by, cx, cy, dx, dy;
String points[] = line.split(" ");
ax = Double.parseDouble(points[0]);
ay = Double.parseDouble(points[1]);
bx = Double.parseDouble(points[2]);
by = Double.parseDouble(points[3]);
cx = Double.parseDouble(points[4]);
cy = Double.parseDouble(points[5]);
dx = Double.parseDouble(points[6]);
dy = Double.parseDouble(points[7]);
if (ax == bx && cy == dy) {
System.out.println("YES");
} else if (ay == by && cx == dx) {
System.out.println("YES");
} else if ((ay - by) * (cy - dy) == (ax - bx) * (cx - dx)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while ((line = br.readLine()) != null) {
double ax, ay, bx, by, cx, cy, dx, dy;
String points[] = line.split(" ");
ax = Double.parseDouble(points[0]);
ay = Double.parseDouble(points[1]);
bx = Double.parseDouble(points[2]);
by = Double.parseDouble(points[3]);
cx = Double.parseDouble(points[4]);
cy = Double.parseDouble(points[5]);
dx = Double.parseDouble(points[6]);
dy = Double.parseDouble(points[7]);
if (ax == bx && cy == dy) {
System.out.println("YES");
} else if (ay == by && cx == dx) {
System.out.println("YES");
} else if ((ay - by) * (cy - dy) * -1 == (ax - bx) * (cx - dx)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
}
|
[["+", 75, 57, 15, 15, 0, 16, 31, 16, 17, 48], ["+", 15, 15, 0, 16, 31, 16, 12, 91, 17, 33], ["+", 15, 15, 0, 16, 31, 16, 12, 91, 439, 499]]
| 3
| 305
|
main() {
float a, b, c, d, e, f, g, h;
while (~scanf("%f%f%f%f%f%f%f%f", &a, &b, &c, &d, &e, &f, &g, &h)) {
puts("%s\n", (c - a) * (g - e) + (d - b) * (h - f) ? "NO" : "YES");
}
exit(0);
}
|
main() {
float a, b, c, d, e, f, g, h;
while (~scanf("%f%f%f%f%f%f%f%f", &a, &b, &c, &d, &e, &f, &g, &h)) {
puts((c - a) * (g - e) + (d - b) * (h - f) ? "NO" : "YES");
}
exit(0);
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 62], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21]]
| 0
| 103
|
#include <stdio.h>
int main(void) {
float xa, ya, xb, yb, xc, yc, xd, yd;
double a1, a2;
double s, l, t, u;
while (scanf("%lf", &xa) != EOF) {
scanf("%f%f%f%f%f%f%f", &ya, &xb, &yb, &xc, &yc, &xd, &yd);
s = xb - xa;
l = yb - ya;
t = xd - xc;
u = yd - yc;
/*a1 = (double)((yb -ya) / (xb - xa));
a2 = (double)((yd -yc) / (xd - xc));*/
if (l * u == -1 * s * t) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
float xa, ya, xb, yb, xc, yc, xd, yd;
double a1, a2;
double s, l, t, u;
while (scanf("%f", &xa) != EOF) {
scanf("%f%f%f%f%f%f%f", &ya, &xb, &yb, &xc, &yc, &xd, &yd);
s = xb - xa;
l = yb - ya;
t = xd - xc;
u = yd - yc;
/*a1 = (double)((yb -ya) / (xb - xa));
a2 = (double)((yd -yc) / (xd - xc));*/
if (l * u == -1 * s * t) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 145
|
#include <stdio.h>
int main(void) {
float xa, ya, xb, yb, xc, yc, xd, yd;
double a1, a2;
double s, l, t, u;
while (scanf("%lf", &xa) != EOF) {
scanf("%f%f%f%f%f%f%f", &ya, &xb, &yb, &xc, &yc, &xd, &yd);
if (xa == xb && yd == yc) {
printf("YES\n");
continue;
}
if (xd == xc && yb == ya) {
printf("YES\n");
continue;
}
if (xb == xa || xd == xc) {
printf("NO\n");
continue;
}
s = xb - xa;
l = yb - ya;
t = xd - xc;
u = yd - yc;
/*a1 = (double)((yb -ya) / (xb - xa));
a2 = (double)((yd -yc) / (xd - xc));*/
if (l * u == -1 * s * t) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
float xa, ya, xb, yb, xc, yc, xd, yd;
double a1, a2;
double s, l, t, u;
while (scanf("%f", &xa) != EOF) {
scanf("%f%f%f%f%f%f%f", &ya, &xb, &yb, &xc, &yc, &xd, &yd);
if (xa == xb && yd == yc) {
printf("YES\n");
continue;
}
if (xd == xc && yb == ya) {
printf("YES\n");
continue;
}
if (xb == xa || xd == xc) {
printf("NO\n");
continue;
}
s = xb - xa;
l = yb - ya;
t = xd - xc;
u = yd - yc;
/*a1 = (double)((yb -ya) / (xb - xa));
a2 = (double)((yd -yc) / (xd - xc));*/
if (l * u == -1 * s * t) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 16, 31, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 211
|
#include <stdio.h>
int main(void) {
double xA, yA, xB, yB, xC, yC, xD, yD;
double dAi, dC;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xA, &yA, &xB, &yB, &xC, &yC, &xD,
&yD) != EOF) {
if (yB == yA) {
puts(xD == xC ? "YES" : "NO");
} else if (xD == xC) {
puts(yB == yA ? "YES" : "NO");
} else {
dAi = (xA - xB) / (yB - yA);
dC = (yD - yC) / (xD - xC);
}
puts(dAi == dC ? "YES" : "NO");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
double xA, yA, xB, yB, xC, yC, xD, yD;
double dAi, dC;
while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xA, &yA, &xB, &yB, &xC, &yC, &xD,
&yD) != EOF) {
if (yB == yA) {
puts(xD == xC ? "YES" : "NO");
} else if (xD == xC) {
puts(yB == yA ? "YES" : "NO");
} else {
dAi = (xA - xB) / (yB - yA);
dC = (yD - yC) / (xD - xC);
puts(dAi == dC ? "YES" : "NO");
}
}
return 0;
}
|
[["-", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 75, 76, 0, 57, 75, 76, 0, 9, 0, 46]]
| 0
| 164
|
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
const int MOD = 1000000007;
const int INF = 1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps = 1e-10;
const int inf = 1e9;
typedef pair<int, int> P;
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;
class Point {
public:
double x, y;
Point(double x, double y) : x(x), y(y) {}
Point operator+(const Point &p) { return Point(x + p.x, y + p.y); }
Point operator-(const Point &p) { return Point(x - p.x, y - p.y); }
Point operator*(double k) { return Point(x * k, y * k); }
Point operator/(double k) { return Point(x / k, y / k); }
bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
bool operator==(const Point &p) const {
return fabs(x - p.x) < eps && fabs(y - p.y) < eps;
}
double abs() { return sqrt(norm()); }
double norm() { return x * x + y * y; }
};
typedef Point 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; }
double norm(Point a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a)); }
struct Segment {
Point p1, p2;
Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};
typedef Segment Line;
class Circle {
public:
Point c;
double r;
Circle(Point c, double r) : c(c), r(r) {}
};
typedef vector<Point> Polygon;
bool isorthogonal(Vector a, Vector b) { return fabs(dot(a, b) - 0.0) < eps; }
bool isparallel(Vector a, Vector b) { return fabs(cross(a, b) - 0.0) < eps; }
Point project(Segment s, Point p) {
Vector base = s.p2 - s.p1;
double r = dot(p - s.p1, base) / norm(base);
return s.p1 + base * r;
}
Point reflect(Segment s, Point p) { return p + (project(s, p) - p) * 2.0; }
double getdistance(Point a, Point b) { return abs(a - b); }
double getdistanceLP(Line l, Point p) {
return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}
double getdistanceSP(Segment s, Point p) {
if (dot(s.p2 - s.p1, p - s.p1) < 0.0)
return abs(p - s.p1);
if (dot(s.p1 - s.p2, p - s.p2) < 0.0)
return abs(p - s.p2);
return getdistanceLP(s, p);
}
int ccw(Point p0, Point p1, Point p2) {
Vector a = p1 - p0;
Vector 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 (a.norm() < b.norm())
return ONLINE_FRONT;
return ON_SEGMENT;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
Point getcrosspoint(Segment s1, Segment s2) {
Vector base = s2.p2 - s2.p1;
double d1 = abs(cross(base, s1.p1 - s2.p1));
double d2 = abs(cross(base, s1.p2 - s2.p1));
double t = d1 / (d1 + d2);
return s1.p1 + (s1.p2 - s1.p1) * t;
}
double getdistanceSS(Segment s1, Segment s2) {
if (intersect(s1, s2))
return 0.0;
return min(min(getdistanceSP(s1, s2.p1), getdistanceSP(s1, s2.p2)),
min(getdistanceSP(s2, s1.p1), getdistanceSP(s2, s1.p2)));
}
pair<Point, Point> getcrosspoints(Circle c, Line l) {
// assert(intersect(c,l));
Vector pr = project(l, c.c);
Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
double base = sqrt(c.r * c.r - norm(pr - c.c));
return make_pair(pr + e * base, pr - e * base);
}
double arg(Vector p) { return atan2(p.y, p.x); }
Vector polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); }
pair<Point, Point> getcrosspoints(Circle c1, Circle c2) {
double d = abs(c1.c - c2.c);
double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
double t = arg(c2.c - c1.c);
return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}
int contains(Polygon g, Point p) {
int n = g.size();
bool x = false;
for (int i = 0; i < n; i++) {
Point a = g[i] - p, b = g[(i + 1) % n] - p;
if (abs(cross(a, b)) < eps && dot(a, b) < eps)
return 1;
if (a.y > b.y)
swap(a, b);
if (a.y < eps && eps < b.y && cross(a, b) > eps)
x = !x;
}
return (x ? 2 : 0);
}
Polygon andrewscan(Polygon s) {
Polygon u, l;
if (s.size() < 3)
return s;
sort(s.begin(), s.end());
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;
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;
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;
}
int main(int argc, char const *argv[]) {
double ax, ay, bx, by, cx, cy, dx, dy;
while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
Vector ab = Vector(bx, by) - Vector(ax, ay);
Vector cd = Vector(dx, dy) - Vector(cx, cy);
if (dot(ab, cd) < eps) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
const int MOD = 1000000007;
const int INF = 1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps = 1e-10;
const int inf = 1e9;
typedef pair<int, int> P;
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;
class Point {
public:
double x, y;
Point(double x, double y) : x(x), y(y) {}
Point operator+(const Point &p) { return Point(x + p.x, y + p.y); }
Point operator-(const Point &p) { return Point(x - p.x, y - p.y); }
Point operator*(double k) { return Point(x * k, y * k); }
Point operator/(double k) { return Point(x / k, y / k); }
bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
bool operator==(const Point &p) const {
return fabs(x - p.x) < eps && fabs(y - p.y) < eps;
}
double abs() { return sqrt(norm()); }
double norm() { return x * x + y * y; }
};
typedef Point 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; }
double norm(Point a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a)); }
struct Segment {
Point p1, p2;
Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};
typedef Segment Line;
class Circle {
public:
Point c;
double r;
Circle(Point c, double r) : c(c), r(r) {}
};
typedef vector<Point> Polygon;
bool isorthogonal(Vector a, Vector b) { return fabs(dot(a, b) - 0.0) < eps; }
bool isparallel(Vector a, Vector b) { return fabs(cross(a, b) - 0.0) < eps; }
Point project(Segment s, Point p) {
Vector base = s.p2 - s.p1;
double r = dot(p - s.p1, base) / norm(base);
return s.p1 + base * r;
}
Point reflect(Segment s, Point p) { return p + (project(s, p) - p) * 2.0; }
double getdistance(Point a, Point b) { return abs(a - b); }
double getdistanceLP(Line l, Point p) {
return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}
double getdistanceSP(Segment s, Point p) {
if (dot(s.p2 - s.p1, p - s.p1) < 0.0)
return abs(p - s.p1);
if (dot(s.p1 - s.p2, p - s.p2) < 0.0)
return abs(p - s.p2);
return getdistanceLP(s, p);
}
int ccw(Point p0, Point p1, Point p2) {
Vector a = p1 - p0;
Vector 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 (a.norm() < b.norm())
return ONLINE_FRONT;
return ON_SEGMENT;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
Point getcrosspoint(Segment s1, Segment s2) {
Vector base = s2.p2 - s2.p1;
double d1 = abs(cross(base, s1.p1 - s2.p1));
double d2 = abs(cross(base, s1.p2 - s2.p1));
double t = d1 / (d1 + d2);
return s1.p1 + (s1.p2 - s1.p1) * t;
}
double getdistanceSS(Segment s1, Segment s2) {
if (intersect(s1, s2))
return 0.0;
return min(min(getdistanceSP(s1, s2.p1), getdistanceSP(s1, s2.p2)),
min(getdistanceSP(s2, s1.p1), getdistanceSP(s2, s1.p2)));
}
pair<Point, Point> getcrosspoints(Circle c, Line l) {
// assert(intersect(c,l));
Vector pr = project(l, c.c);
Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
double base = sqrt(c.r * c.r - norm(pr - c.c));
return make_pair(pr + e * base, pr - e * base);
}
double arg(Vector p) { return atan2(p.y, p.x); }
Vector polar(double a, double r) { return Point(cos(r) * a, sin(r) * a); }
pair<Point, Point> getcrosspoints(Circle c1, Circle c2) {
double d = abs(c1.c - c2.c);
double a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
double t = arg(c2.c - c1.c);
return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}
int contains(Polygon g, Point p) {
int n = g.size();
bool x = false;
for (int i = 0; i < n; i++) {
Point a = g[i] - p, b = g[(i + 1) % n] - p;
if (abs(cross(a, b)) < eps && dot(a, b) < eps)
return 1;
if (a.y > b.y)
swap(a, b);
if (a.y < eps && eps < b.y && cross(a, b) > eps)
x = !x;
}
return (x ? 2 : 0);
}
Polygon andrewscan(Polygon s) {
Polygon u, l;
if (s.size() < 3)
return s;
sort(s.begin(), s.end());
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;
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;
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;
}
int main(int argc, char const *argv[]) {
double ax, ay, bx, by, cx, cy, dx, dy;
while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
Vector ab = Vector(bx, by) - Vector(ax, ay);
Vector cd = Vector(dx, dy) - Vector(cx, cy);
if (abs(dot(ab, cd)) < eps) {
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], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
| 1
| 1,953
|
/*include*/
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a);
push_back(b);
}
};
#define curr(P, i) P[i]
#define next(P, i) P[(i + 1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
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);
}
} // namespace std
P pin() {
double x, y;
cin >> x >> y;
P p(x, y);
return p;
}
void PIN(P *a, int n) { rep(i, n) a[i] = pin(); }
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
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;
}
P projection(L a, P p) {
double t = dot(p - a[0], a[0] - a[1]) / norm(a[0] - a[1]);
return a[0] + t * (a[0] - a[1]);
}
P reflection(L a, P p) { return p + 2.0 * (projection(a, p) - p); }
bool intersectLL(const L &l, const L &m) {
return abs(cross(l[1] - l[0], m[1] - m[0])) > EPS || // non-parallel
abs(cross(l[1] - l[0], m[0] - l[0])) < EPS; // same line
}
bool intersectLS(const L &l, const L &s) {
return cross(l[1] - l[0], s[0] - l[0]) * // s[0] is left of l
cross(l[1] - l[0], s[1] - l[0]) <
EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
return abs(cross(l[1] - p, l[0] - p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) <
EPS; // triangle inequality
}
P intersect_ls(L a, L b) {
double t1 = abs(cross(a[1] - a[0], b[0] - a[0]));
double t2 = abs(cross(a[1] - a[0], b[1] - a[0]));
return b[0] + (b[1] - b[0]) * t1 / (t1 + t2);
}
double distanceLP(const L &l, const P &p) {
if (dot(l[1] - l[0], p - l[0]) < EPS)
return abs(p - l[0]);
if (dot(l[0] - l[1], p - l[1]) < EPS)
return abs(p - l[1]);
return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
if (intersectLS(l, s))
return 0;
return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
const P r = projection(s, p);
if (intersectSP(s, r))
return abs(r - p);
return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
if (intersectSS(s, t))
return 0;
return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
bool intersectCL(P c, double r, const L &l) {
return (distanceLP(l, c) < r + EPS &&
(r < abs(c - l[0]) + EPS || r < abs(c - l[1]) + EPS));
}
L circles_point(P c1, double r1, P c2, double r2) {
double d = abs(c1 - c2);
double s = (r1 + r2 + d) / 2;
double S = sqrt(s * (s - r1) * (s - r2) * (s - d));
double h = 2 * S / d;
P v = (c2 - c1) / (abs(c2 - c1));
double m = sqrt(r1 * r1 - h * h);
P a = c1 + m * v + h * v * P(0, 1);
P b = c1 + m * v - h * v * P(0, 1);
if (b < a)
swap(a, b);
return L(a, b);
}
P crosspoint(const L &l, const L &m) {
double A = cross(l[1] - l[0], m[1] - m[0]);
double B = cross(l[1] - l[0], l[1] - m[0]);
if (abs(A) < EPS && abs(B) < EPS)
return m[0]; // same line
return m[0] + B / A * (m[1] - m[0]);
}
double area(const G &g) {
double S = 0;
for (int i = 0; i < g.size(); i++) {
S += (cross(g[i], g[(i + 1) % g.size()]));
}
return abs(S / 2.0);
}
bool isconvex(const G &g) {
int n = g.size();
rep(i, n) if (ccw(g[(i + n - 1) % n], g[i % n], g[(i + 1) % n]) ==
-1) return false;
return true;
}
int contain(const G &g, const P &p) {
bool in = false;
int n = g.size();
rep(i, n) {
P a = g[i % n] - p;
P b = g[(i + 1) % n] - p;
if (imag(a) > imag(b))
swap(a, b);
if (imag(a) <= 0 && 0 < imag(b))
if (cross(a, b) < 0)
in = !in;
if (cross(a, b) == 0 && dot(a, b) <= 0)
return 1; // ON
}
return in ? 2 : 0; // IN : OUT;
}
G convex_hull(G &ps) {
int n = ps.size(), k = 0;
sort(ps.begin(), ps.end());
G ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) == -1)
--k; //<=0 -> ==-1
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) // upper-hull
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) == -1)
--k; //
ch.resize(k - 1);
return ch;
}
double convex_diameter(const G &pt) {
const int n = pt.size();
int is = 0, js = 0;
for (int i = 1; i < n; ++i) {
if (imag(pt[i]) > imag(pt[is]))
is = i;
if (imag(pt[i]) < imag(pt[js]))
js = i;
}
double maxd = norm(pt[is] - pt[js]);
int i, maxi, j, maxj;
i = maxi = is;
j = maxj = js;
do {
if (cross(diff(pt, i), diff(pt, j)) >= 0)
j = (j + 1) % n;
else
i = (i + 1) % n;
if (norm(pt[i] - pt[j]) > maxd) {
maxd = norm(pt[i] - pt[j]);
maxi = i;
maxj = j;
}
} while (i != is || j != js);
return sqrt(maxd); /* farthest pair is (maxi, maxj). */
} // convex_diameter(g)
G convex_cut(const G &g, const L &l) {
G Q;
for (int i = 0; i < g.size(); ++i) {
P a = curr(g, i), b = next(g, i);
if (ccw(l[0], l[1], a) != -1)
Q.push_back(a);
if (ccw(l[0], l[1], a) * ccw(l[0], l[1], b) < 0)
Q.push_back(crosspoint(L(a, b), l));
}
return Q;
}
P turn(P p, double t) { return p * exp(P(.0, t * PI / 180.0)); }
int main() {
double x, y;
while (cin >> x >> y) {
P p[4];
p[0] = P(x, y);
PIN(&p[1], 3);
if ((dot(p[0] - p[1], p[2] - p[3])) < EPS)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
/*include*/
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
struct L : public vector<P> {
L(const P &a, const P &b) {
push_back(a);
push_back(b);
}
};
#define curr(P, i) P[i]
#define next(P, i) P[(i + 1) % P.size()]
#define diff(P, i) (next(P, i) - curr(P, i))
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);
}
} // namespace std
P pin() {
double x, y;
cin >> x >> y;
P p(x, y);
return p;
}
void PIN(P *a, int n) { rep(i, n) a[i] = pin(); }
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
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;
}
P projection(L a, P p) {
double t = dot(p - a[0], a[0] - a[1]) / norm(a[0] - a[1]);
return a[0] + t * (a[0] - a[1]);
}
P reflection(L a, P p) { return p + 2.0 * (projection(a, p) - p); }
bool intersectLL(const L &l, const L &m) {
return abs(cross(l[1] - l[0], m[1] - m[0])) > EPS || // non-parallel
abs(cross(l[1] - l[0], m[0] - l[0])) < EPS; // same line
}
bool intersectLS(const L &l, const L &s) {
return cross(l[1] - l[0], s[0] - l[0]) * // s[0] is left of l
cross(l[1] - l[0], s[1] - l[0]) <
EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
return abs(cross(l[1] - p, l[0] - p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) <
EPS; // triangle inequality
}
P intersect_ls(L a, L b) {
double t1 = abs(cross(a[1] - a[0], b[0] - a[0]));
double t2 = abs(cross(a[1] - a[0], b[1] - a[0]));
return b[0] + (b[1] - b[0]) * t1 / (t1 + t2);
}
double distanceLP(const L &l, const P &p) {
if (dot(l[1] - l[0], p - l[0]) < EPS)
return abs(p - l[0]);
if (dot(l[0] - l[1], p - l[1]) < EPS)
return abs(p - l[1]);
return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
if (intersectLS(l, s))
return 0;
return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
const P r = projection(s, p);
if (intersectSP(s, r))
return abs(r - p);
return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
if (intersectSS(s, t))
return 0;
return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
bool intersectCL(P c, double r, const L &l) {
return (distanceLP(l, c) < r + EPS &&
(r < abs(c - l[0]) + EPS || r < abs(c - l[1]) + EPS));
}
L circles_point(P c1, double r1, P c2, double r2) {
double d = abs(c1 - c2);
double s = (r1 + r2 + d) / 2;
double S = sqrt(s * (s - r1) * (s - r2) * (s - d));
double h = 2 * S / d;
P v = (c2 - c1) / (abs(c2 - c1));
double m = sqrt(r1 * r1 - h * h);
P a = c1 + m * v + h * v * P(0, 1);
P b = c1 + m * v - h * v * P(0, 1);
if (b < a)
swap(a, b);
return L(a, b);
}
P crosspoint(const L &l, const L &m) {
double A = cross(l[1] - l[0], m[1] - m[0]);
double B = cross(l[1] - l[0], l[1] - m[0]);
if (abs(A) < EPS && abs(B) < EPS)
return m[0]; // same line
return m[0] + B / A * (m[1] - m[0]);
}
double area(const G &g) {
double S = 0;
for (int i = 0; i < g.size(); i++) {
S += (cross(g[i], g[(i + 1) % g.size()]));
}
return abs(S / 2.0);
}
bool isconvex(const G &g) {
int n = g.size();
rep(i, n) if (ccw(g[(i + n - 1) % n], g[i % n], g[(i + 1) % n]) ==
-1) return false;
return true;
}
int contain(const G &g, const P &p) {
bool in = false;
int n = g.size();
rep(i, n) {
P a = g[i % n] - p;
P b = g[(i + 1) % n] - p;
if (imag(a) > imag(b))
swap(a, b);
if (imag(a) <= 0 && 0 < imag(b))
if (cross(a, b) < 0)
in = !in;
if (cross(a, b) == 0 && dot(a, b) <= 0)
return 1; // ON
}
return in ? 2 : 0; // IN : OUT;
}
G convex_hull(G &ps) {
int n = ps.size(), k = 0;
sort(ps.begin(), ps.end());
G ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) == -1)
--k; //<=0 -> ==-1
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--]) // upper-hull
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) == -1)
--k; //
ch.resize(k - 1);
return ch;
}
double convex_diameter(const G &pt) {
const int n = pt.size();
int is = 0, js = 0;
for (int i = 1; i < n; ++i) {
if (imag(pt[i]) > imag(pt[is]))
is = i;
if (imag(pt[i]) < imag(pt[js]))
js = i;
}
double maxd = norm(pt[is] - pt[js]);
int i, maxi, j, maxj;
i = maxi = is;
j = maxj = js;
do {
if (cross(diff(pt, i), diff(pt, j)) >= 0)
j = (j + 1) % n;
else
i = (i + 1) % n;
if (norm(pt[i] - pt[j]) > maxd) {
maxd = norm(pt[i] - pt[j]);
maxi = i;
maxj = j;
}
} while (i != is || j != js);
return sqrt(maxd); /* farthest pair is (maxi, maxj). */
} // convex_diameter(g)
G convex_cut(const G &g, const L &l) {
G Q;
for (int i = 0; i < g.size(); ++i) {
P a = curr(g, i), b = next(g, i);
if (ccw(l[0], l[1], a) != -1)
Q.push_back(a);
if (ccw(l[0], l[1], a) * ccw(l[0], l[1], b) < 0)
Q.push_back(crosspoint(L(a, b), l));
}
return Q;
}
P turn(P p, double t) { return p * exp(P(.0, t * PI / 180.0)); }
int main() {
double x, y;
while (cin >> x >> y) {
P p[4];
p[0] = P(x, y);
PIN(&p[1], 3);
if (abs(dot(p[0] - p[1], p[2] - p[3])) < EPS)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22]]
| 1
| 2,525
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class t> using table = vector<vector<t>>;
const ld eps = 1e-9;
// < "d:\d_download\visual studio
// 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
// studio 2015\projects\programing_contest_c++\debug\b.answer"
/* ??????????????¬ */
#include <complex>
typedef complex<ld> Point;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;
namespace std {
bool operator<(const Point &lhs, const Point &rhs) {
if (lhs.real() < rhs.real() - eps)
return true;
if (lhs.real() > rhs.real() + eps)
return false;
return lhs.imag() < rhs.imag();
}
} // namespace std
// ????????\???
Point input_Point() {
ld x, y;
cin >> x >> y;
return Point(x, y);
}
// ????????????????????????
bool eq(const ld a, const ld b) { return (abs(a - b) < eps); }
// ??????
ld dot(const Point &a, const Point &b) { return real(conj(a) * b); }
// ??????
ld cross(const Point &a, const Point &b) { return imag(conj(a) * b); }
// ??´????????????
class Line {
public:
Point a, b;
Line() : a(Point(0, 0)), b(Point(0, 0)) {}
Line(Point a, Point b) : a(a), b(b) {}
Point operator[](const int _num) const {
if (_num == 0)
return a;
else if (_num == 1)
return b;
else {
assert(false);
return Point();
}
}
};
// ????????????
class Circle {
public:
Point p;
ld r;
Circle() : p(Point(0, 0)), r(0) {}
Circle(Point p, ld r) : p(p), r(r) {}
};
// ccw
int ccw(const Point &a, const Point &b, const Point &c) {
const Point nb(b - a);
const Point nc(c - a);
if (cross(nb, nc) > eps)
return 1; // a,b,c??????????¨???¨?????????????????¶
if (cross(nb, nc) < -eps)
return -1; // a,b,c???????¨???¨?????????????????¶
if (dot(nb, nc) < 0)
return 2; // c,a,b???????????´???????????¶
if (norm(nb) < norm(nc))
return -2; // a,b,c???????????´???????????¶
return 0; // a,c,b???????????´???????????¶
}
/* ???????????? */
// ??´?????¨??´??????????????????
bool isis_ll(const Line &l, const Line &m) {
return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
// ??´?????¨?????????????????????
bool isis_ls(const Line &l, const Line &s) {
return isis_ll(l, s) &&
(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
// ????????¨?????????????????????
bool isis_ss(const Line &s, const Line &t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
// ????????´????????????
bool isis_lp(const Line &l, const Point &p) {
return (abs(cross(l.b - p, l.a - p)) < eps);
}
// ?????????????????????
bool isis_sp(const Line &s, const Point &p) {
return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
// ??????????¶?
Point proj(const Line &l, const Point &p) {
ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + t * (l.a - l.b);
}
// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
assert(cross(sv, tv) != 0);
return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
if (cross(sv, tv) != 0)
return vector<Point>(1, is_ll(s, t));
else {
vector<Point> ans;
for (int k = 0; k < 2; ++k) {
if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())
ans.push_back(t[k]);
if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())
ans.push_back(s[k]);
}
return ans;
}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line &t) {
if (isis_ss(s, t)) {
for (int k = 0; k < 2; ++k) {
for (int l = 0; l < 2; ++l) {
if (s[k] == t[l])
return s[k];
}
}
return is_ll(s, t);
} else {
//??????isis_ss?????????
assert(false);
return Point(0, 0);
}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line &t) {
vector<Point> kouho(is_ll2(s, t));
vector<Point> ans;
for (auto p : kouho) {
if (isis_sp(s, p) && isis_sp(t, p))
ans.emplace_back(p);
}
return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line &l, const Point &p) { return abs(p - proj(l, p)); }
//??´?????¨??´???????????¢
ld dist_ll(const Line &l, const Line &m) {
return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
// ??´?????¨??????????????¢
ld dist_ls(const Line &l, const Line &s) {
return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
// ????????¨???????????¢
ld dist_sp(const Line &s, const Point &p) {
Point r = proj(s, p);
return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
// ????????¨??????????????¢
ld dist_ss(const Line &s, const Line &t) {
if (isis_ss(s, t))
return 0;
return min(
{dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}
//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
const Point laglanju(is_ll(s, t));
const Point avec =
!(abs(laglanju - s[0]) < eps) ? s[0] - laglanju : s[1] - laglanju;
const Point bvec =
!(abs(laglanju - t[0]) < eps) ? t[0] - laglanju : t[1] - laglanju;
return Line(laglanju, laglanju + (abs(bvec) * avec + abs(avec) * bvec) /
(abs(avec) + abs(bvec)));
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point inner_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (vertics[0] == vertics[1] || vertics[1] == vertics[2] ||
vertics[2] == vertics[0])
return vertics[0];
Line bi1(
bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
Line bi2(
bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
if (bi1[0] == bi2[0])
return bi1[0];
else {
return is_ll(bi1, bi2);
}
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point> ex_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (abs(vertics[0] - vertics[1]) < eps ||
abs(vertics[1] - vertics[2]) < eps ||
(abs(vertics[2] - vertics[0]) < eps))
return vector<Point>();
vector<Point> ecs;
for (int i = 0; i < 3; ++i) {
Line bi1(
bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[i], vertics[(i + 1) % 3])));
Line bi2(bisection(Line(vertics[(i + 1) % 3],
vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[(i + 1) % 3], vertics[i])));
ecs.push_back(is_ll(bi1, bi2));
}
return ecs;
}
// a,b:??????
// c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point> same_dis(const vector<Line> &ls) {
vector<Point> vertics;
vertics.push_back(is_ll(ls[0], ls[2]));
vertics.push_back(is_ll(ls[1], ls[2]));
if (abs(vertics[0] - vertics[1]) < eps)
return vector<Point>{vertics[0]};
Line bis(bisection(ls[0], ls[1]));
vector<Point> ecs;
Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, abi));
Line bbi(bisection(Line(vertics[0], 2.l * vertics[0] - vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, bbi));
return ecs;
}
/* ??? */
// ?????¨????????????
vector<Point> is_cc(const Circle &c1, const Circle &c2) {
vector<Point> res;
ld d = abs(c1.p - c2.p);
ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
ld dfr = c1.r * c1.r - rc * rc;
if (abs(dfr) < eps)
dfr = 0.0;
else if (dfr < 0.0)
return res; // no intersection
ld rs = sqrt(dfr);
Point diff = (c2.p - c1.p) / d;
res.push_back(c1.p + diff * Point(rc, rs));
if (dfr != 0.0)
res.push_back(c1.p + diff * Point(rc, -rs));
return res;
}
//???????????????????????????
/* 0 => out
1 => on
2 => in*/
int is_in_Circle(const Circle &cir, const Point &p) {
ld dis = abs(cir.p - p);
if (dis > cir.r + eps)
return 0;
else if (dis < cir.r - eps)
return 2;
else
return 1;
}
//???lc??????rc??????????????????
/*0 => out
1 => on
2 => in*/
int Circle_in_Circle(const Circle &lc, const Circle &rc) {
ld dis = abs(lc.p - rc.p);
if (dis < rc.r - lc.r - eps)
return 2;
else if (dis > rc.r - lc.r + eps)
return 0;
else
return 1;
}
// ?????¨??´????????????
vector<Point> is_lc(const Circle &c, const Line &l) {
vector<Point> res;
ld d = dist_lp(l, c.p);
if (d < c.r + eps) {
ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); // safety;
Point nor = (l.a - l.b) / abs(l.a - l.b);
res.push_back(proj(l, c.p) + len * nor);
res.push_back(proj(l, c.p) - len * nor);
}
return res;
}
// ?????¨??????????????¢
vector<Point> is_sc(const Circle &c, const Line &l) {
vector<Point> v = is_lc(c, l), res;
for (Point p : v)
if (isis_sp(l, p))
res.push_back(p);
return res;
}
// ?????¨????????\???
vector<Line> tangent_cp(const Circle &c, const Point &p) {
vector<Line> ret;
Point v = c.p - p;
ld d = abs(v);
ld l = sqrt(norm(v) - c.r * c.r);
if (isnan(l)) {
return ret;
}
Point v1 = v * Point(l / d, c.r / d);
Point v2 = v * Point(l / d, -c.r / d);
ret.push_back(Line(p, p + v1));
if (l < eps)
return ret;
ret.push_back(Line(p, p + v2));
return ret;
}
// ?????¨????????\???
vector<Line> tangent_cc(const Circle &c1, const Circle &c2) {
vector<Line> ret;
if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
ret = tangent_cp(c1, center);
}
if (abs(c1.r - c2.r) > eps) {
Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
vector<Line> nret = tangent_cp(c1, out);
ret.insert(ret.end(), all(nret));
} else {
Point v = c2.p - c1.p;
v /= abs(v);
Point q1 = c1.p + v * Point(0, 1) * c1.r;
Point q2 = c1.p + v * Point(0, -1) * c1.r;
ret.push_back(Line(q1, q1 + v));
ret.push_back(Line(q2, q2 + v));
}
return ret;
}
//??????????????????????????¢???
ld two_Circle_area(const Circle &l, const Circle &r) {
ld dis = abs(l.p - r.p);
if (dis > l.r + r.r)
return 0;
else if (dis + r.r < l.r) {
return r.r * r.r * pi;
} else if (dis + l.r < r.r) {
return l.r * l.r * pi;
} else {
ld ans = (l.r) * (l.r) *
acos((dis * dis + l.r * l.r - r.r * r.r) / (2 * dis * l.r)) +
(r.r) * (r.r) *
acos((dis * dis + r.r * r.r - l.r * l.r) / (2 * dis * r.r)) -
sqrt(4 * dis * dis * l.r * l.r -
(dis * dis + l.r * l.r - r.r * r.r) *
(dis * dis + l.r * l.r - r.r * r.r)) /
2;
return ans;
}
}
/* ????§???¢ */
typedef vector<Point> Polygon;
// ??¢???
ld area(const Polygon &p) {
ld res = 0;
int n = p.size();
rep(j, n) res += cross(p[j], p[(j + 1) % n]);
return res / 2;
}
//????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
angle += arg((c - b) / (b - a));
}
return angle > eps;
}
// ??????????????????
/*0 => out
1 => on
2 => in*/
int is_in_Polygon(const Polygon &poly, const Point &p) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n];
if (isis_sp(Line(a, b), p))
return 1;
angle += arg((b - p) / (a - p));
}
return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { out, on, in };
int convex_contains(const Polygon &P, const Point &p) {
const int n = P.size();
Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
int a = 0, b = n;
while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
int c = (a + b) / 2;
if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0)
b = c;
else
a = c;
} else {
if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0)
a = c;
else
b = c;
}
}
b %= n;
if (cross(P[a] - p, P[b] - p) < 0)
return 0;
if (cross(P[a] - p, P[b] - p) > 0)
return 2;
return 1;
}
// ??????
//???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
int n = ps.size();
int k = 0;
sort(ps.begin(), ps.end());
Polygon ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++])
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
ch.resize(k - 1);
return ch;
}
//????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line &l) {
int n = ps.size();
Polygon q;
Polygon r;
rep(i, n) {
Point a = ps[i], b = ps[(i + 1) % n];
Line m = Line(a, b);
if (ccw(l.a, l.b, a) != -1)
q.push_back(a);
if (ccw(l.a, l.b, a) != 1)
r.push_back(a);
if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0 && isis_ll(l, m)) {
q.push_back(is_ll(l, m));
r.push_back(is_ll(l, m));
}
}
const vector<Polygon> polys{q, r};
return polys;
}
/* ??¢??¬??????????????? */
void add_Point(vector<Point> &ps, const Point p) {
for (Point q : ps)
if (abs(q - p) < eps)
return;
ps.push_back(p);
}
typedef int Weight;
struct edge {
int src, dst;
Weight weight;
edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
typedef vector<edge> edges;
typedef vector<edges> graph;
void add_edge(graph &g, const int from, const int to, const Weight weight) {
g[from].push_back(edge{from, to, weight});
}
graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
int n = p.size(), m = s.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (isis_sp(s[i], p[j])) vec.emplace_back(abs(s[i].a - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
}
}
return g;
}
graph sennbunn_arrangement(const vector<Line> &s) {
vector<Point> crss;
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
if (isis_ss(s[i], s[j])) {
crss.push_back(is_ll2(s[i], s[j])[0]);
}
}
}
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
crss.push_back(s[i][0]);
crss.push_back(s[i][1]);
}
return segment_arrangement(s, crss);
}
graph Circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
int n = p.size(), m = c.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
vec.emplace_back(arg(c[i].p - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
ld angle = vec[j + 1].first - vec[j].first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
if (vec.size() >= 2) {
int from = vec.back().second, to = vec.front().first;
ld angle = vec.front().first - vec.back().first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
}
return g;
}
int main() {
ld xa, ya, xb, yb, xc, yc, xd, yd;
while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
Line l(Point(xa, ya), Point(xb, yb));
Line r(Point(xc, yc), Point(xd, yd));
if (isis_ll(l, r)) {
ld ans = (dot((l[1] - l[0]), (r[1] - r[0])) / abs(l[1] - l[0])) /
abs(r[1] - r[0]);
if (ans < eps / 100) {
cout << "YES" << endl;
continue;
}
}
cout << "NO" << endl;
}
return 0;
}
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class t> using table = vector<vector<t>>;
const ld eps = 1e-9;
// < "d:\d_download\visual studio
// 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
// studio 2015\projects\programing_contest_c++\debug\b.answer"
/* ??????????????¬ */
#include <complex>
typedef complex<ld> Point;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = acos(-1.0);
const ld dtop = pi / 180.;
const ld ptod = 1. / dtop;
namespace std {
bool operator<(const Point &lhs, const Point &rhs) {
if (lhs.real() < rhs.real() - eps)
return true;
if (lhs.real() > rhs.real() + eps)
return false;
return lhs.imag() < rhs.imag();
}
} // namespace std
// ????????\???
Point input_Point() {
ld x, y;
cin >> x >> y;
return Point(x, y);
}
// ????????????????????????
bool eq(const ld a, const ld b) { return (abs(a - b) < eps); }
// ??????
ld dot(const Point &a, const Point &b) { return real(conj(a) * b); }
// ??????
ld cross(const Point &a, const Point &b) { return imag(conj(a) * b); }
// ??´????????????
class Line {
public:
Point a, b;
Line() : a(Point(0, 0)), b(Point(0, 0)) {}
Line(Point a, Point b) : a(a), b(b) {}
Point operator[](const int _num) const {
if (_num == 0)
return a;
else if (_num == 1)
return b;
else {
assert(false);
return Point();
}
}
};
// ????????????
class Circle {
public:
Point p;
ld r;
Circle() : p(Point(0, 0)), r(0) {}
Circle(Point p, ld r) : p(p), r(r) {}
};
// ccw
int ccw(const Point &a, const Point &b, const Point &c) {
const Point nb(b - a);
const Point nc(c - a);
if (cross(nb, nc) > eps)
return 1; // a,b,c??????????¨???¨?????????????????¶
if (cross(nb, nc) < -eps)
return -1; // a,b,c???????¨???¨?????????????????¶
if (dot(nb, nc) < 0)
return 2; // c,a,b???????????´???????????¶
if (norm(nb) < norm(nc))
return -2; // a,b,c???????????´???????????¶
return 0; // a,c,b???????????´???????????¶
}
/* ???????????? */
// ??´?????¨??´??????????????????
bool isis_ll(const Line &l, const Line &m) {
return !eq(cross(l.b - l.a, m.b - m.a), 0);
}
// ??´?????¨?????????????????????
bool isis_ls(const Line &l, const Line &s) {
return isis_ll(l, s) &&
(cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
// ????????¨?????????????????????
bool isis_ss(const Line &s, const Line &t) {
return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
// ????????´????????????
bool isis_lp(const Line &l, const Point &p) {
return (abs(cross(l.b - p, l.a - p)) < eps);
}
// ?????????????????????
bool isis_sp(const Line &s, const Point &p) {
return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
// ??????????¶?
Point proj(const Line &l, const Point &p) {
ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + t * (l.a - l.b);
}
// ??´?????¨??´????????????
Point is_ll(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
assert(cross(sv, tv) != 0);
return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
// ??´?????¨??´????????????
vector<Point> is_ll2(const Line &s, const Line &t) {
Point sv = s.b - s.a, tv = t.b - t.a;
if (cross(sv, tv) != 0)
return vector<Point>(1, is_ll(s, t));
else {
vector<Point> ans;
for (int k = 0; k < 2; ++k) {
if (isis_sp(s, t[k]) && find(ans.begin(), ans.end(), t[k]) == ans.end())
ans.push_back(t[k]);
if (isis_sp(t, s[k]) && find(ans.begin(), ans.end(), s[k]) == ans.end())
ans.push_back(s[k]);
}
return ans;
}
}
// ????????¨???????????????
//???????????£????????¨???????????¨assert(false)
Point is_ss(const Line &s, const Line &t) {
if (isis_ss(s, t)) {
for (int k = 0; k < 2; ++k) {
for (int l = 0; l < 2; ++l) {
if (s[k] == t[l])
return s[k];
}
}
return is_ll(s, t);
} else {
//??????isis_ss?????????
assert(false);
return Point(0, 0);
}
}
// ????????¨???????????????
vector<Point> is_ss2(const Line &s, const Line &t) {
vector<Point> kouho(is_ll2(s, t));
vector<Point> ans;
for (auto p : kouho) {
if (isis_sp(s, p) && isis_sp(t, p))
ans.emplace_back(p);
}
return ans;
}
// ??´?????¨???????????¢
ld dist_lp(const Line &l, const Point &p) { return abs(p - proj(l, p)); }
//??´?????¨??´???????????¢
ld dist_ll(const Line &l, const Line &m) {
return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
// ??´?????¨??????????????¢
ld dist_ls(const Line &l, const Line &s) {
return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
// ????????¨???????????¢
ld dist_sp(const Line &s, const Point &p) {
Point r = proj(s, p);
return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
// ????????¨??????????????¢
ld dist_ss(const Line &s, const Line &t) {
if (isis_ss(s, t))
return 0;
return min(
{dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}
//??´?????¨??´?????????????????????????????????
Line bisection(const Line &s, const Line &t) {
const Point laglanju(is_ll(s, t));
const Point avec =
!(abs(laglanju - s[0]) < eps) ? s[0] - laglanju : s[1] - laglanju;
const Point bvec =
!(abs(laglanju - t[0]) < eps) ? t[0] - laglanju : t[1] - laglanju;
return Line(laglanju, laglanju + (abs(bvec) * avec + abs(avec) * bvec) /
(abs(avec) + abs(bvec)));
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
Point inner_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (vertics[0] == vertics[1] || vertics[1] == vertics[2] ||
vertics[2] == vertics[0])
return vertics[0];
Line bi1(
bisection(Line(vertics[0], vertics[1]), Line(vertics[0], vertics[2])));
Line bi2(
bisection(Line(vertics[1], vertics[2]), Line(vertics[1], vertics[0])));
if (bi1[0] == bi2[0])
return bi1[0];
else {
return is_ll(bi1, bi2);
}
}
//???????????´?????????????????????
//???????????´??????????????§???????????¨????¢?????????¨?????????
vector<Point> ex_center(const vector<Line> &ls) {
vector<Point> vertics;
for (int i = 0; i < static_cast<int>(ls.size()); ++i) {
vertics.push_back(is_ll(ls[i], ls[(i + 1) % 3]));
}
if (abs(vertics[0] - vertics[1]) < eps ||
abs(vertics[1] - vertics[2]) < eps ||
(abs(vertics[2] - vertics[0]) < eps))
return vector<Point>();
vector<Point> ecs;
for (int i = 0; i < 3; ++i) {
Line bi1(
bisection(Line(vertics[i], vertics[i] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[i], vertics[(i + 1) % 3])));
Line bi2(bisection(Line(vertics[(i + 1) % 3],
vertics[(i + 1) % 3] * 2.0l - vertics[(i + 2) % 3]),
Line(vertics[(i + 1) % 3], vertics[i])));
ecs.push_back(is_ll(bi1, bi2));
}
return ecs;
}
// a,b:??????
// c:????????§??????
//???????????´?????????????????¢?????????????±??????????
vector<Point> same_dis(const vector<Line> &ls) {
vector<Point> vertics;
vertics.push_back(is_ll(ls[0], ls[2]));
vertics.push_back(is_ll(ls[1], ls[2]));
if (abs(vertics[0] - vertics[1]) < eps)
return vector<Point>{vertics[0]};
Line bis(bisection(ls[0], ls[1]));
vector<Point> ecs;
Line abi(bisection(Line(vertics[0], vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, abi));
Line bbi(bisection(Line(vertics[0], 2.l * vertics[0] - vertics[1]), ls[0]));
ecs.push_back(is_ll(bis, bbi));
return ecs;
}
/* ??? */
// ?????¨????????????
vector<Point> is_cc(const Circle &c1, const Circle &c2) {
vector<Point> res;
ld d = abs(c1.p - c2.p);
ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
ld dfr = c1.r * c1.r - rc * rc;
if (abs(dfr) < eps)
dfr = 0.0;
else if (dfr < 0.0)
return res; // no intersection
ld rs = sqrt(dfr);
Point diff = (c2.p - c1.p) / d;
res.push_back(c1.p + diff * Point(rc, rs));
if (dfr != 0.0)
res.push_back(c1.p + diff * Point(rc, -rs));
return res;
}
//???????????????????????????
/* 0 => out
1 => on
2 => in*/
int is_in_Circle(const Circle &cir, const Point &p) {
ld dis = abs(cir.p - p);
if (dis > cir.r + eps)
return 0;
else if (dis < cir.r - eps)
return 2;
else
return 1;
}
//???lc??????rc??????????????????
/*0 => out
1 => on
2 => in*/
int Circle_in_Circle(const Circle &lc, const Circle &rc) {
ld dis = abs(lc.p - rc.p);
if (dis < rc.r - lc.r - eps)
return 2;
else if (dis > rc.r - lc.r + eps)
return 0;
else
return 1;
}
// ?????¨??´????????????
vector<Point> is_lc(const Circle &c, const Line &l) {
vector<Point> res;
ld d = dist_lp(l, c.p);
if (d < c.r + eps) {
ld len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d); // safety;
Point nor = (l.a - l.b) / abs(l.a - l.b);
res.push_back(proj(l, c.p) + len * nor);
res.push_back(proj(l, c.p) - len * nor);
}
return res;
}
// ?????¨??????????????¢
vector<Point> is_sc(const Circle &c, const Line &l) {
vector<Point> v = is_lc(c, l), res;
for (Point p : v)
if (isis_sp(l, p))
res.push_back(p);
return res;
}
// ?????¨????????\???
vector<Line> tangent_cp(const Circle &c, const Point &p) {
vector<Line> ret;
Point v = c.p - p;
ld d = abs(v);
ld l = sqrt(norm(v) - c.r * c.r);
if (isnan(l)) {
return ret;
}
Point v1 = v * Point(l / d, c.r / d);
Point v2 = v * Point(l / d, -c.r / d);
ret.push_back(Line(p, p + v1));
if (l < eps)
return ret;
ret.push_back(Line(p, p + v2));
return ret;
}
// ?????¨????????\???
vector<Line> tangent_cc(const Circle &c1, const Circle &c2) {
vector<Line> ret;
if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
ret = tangent_cp(c1, center);
}
if (abs(c1.r - c2.r) > eps) {
Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
vector<Line> nret = tangent_cp(c1, out);
ret.insert(ret.end(), all(nret));
} else {
Point v = c2.p - c1.p;
v /= abs(v);
Point q1 = c1.p + v * Point(0, 1) * c1.r;
Point q2 = c1.p + v * Point(0, -1) * c1.r;
ret.push_back(Line(q1, q1 + v));
ret.push_back(Line(q2, q2 + v));
}
return ret;
}
//??????????????????????????¢???
ld two_Circle_area(const Circle &l, const Circle &r) {
ld dis = abs(l.p - r.p);
if (dis > l.r + r.r)
return 0;
else if (dis + r.r < l.r) {
return r.r * r.r * pi;
} else if (dis + l.r < r.r) {
return l.r * l.r * pi;
} else {
ld ans = (l.r) * (l.r) *
acos((dis * dis + l.r * l.r - r.r * r.r) / (2 * dis * l.r)) +
(r.r) * (r.r) *
acos((dis * dis + r.r * r.r - l.r * l.r) / (2 * dis * r.r)) -
sqrt(4 * dis * dis * l.r * l.r -
(dis * dis + l.r * l.r - r.r * r.r) *
(dis * dis + l.r * l.r - r.r * r.r)) /
2;
return ans;
}
}
/* ????§???¢ */
typedef vector<Point> Polygon;
// ??¢???
ld area(const Polygon &p) {
ld res = 0;
int n = p.size();
rep(j, n) res += cross(p[j], p[(j + 1) % n]);
return res / 2;
}
//????§???¢????????¢??????
bool is_counter_clockwise(const Polygon &poly) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n], c = poly[(i + 2) % n];
angle += arg((c - b) / (b - a));
}
return angle > eps;
}
// ??????????????????
/*0 => out
1 => on
2 => in*/
int is_in_Polygon(const Polygon &poly, const Point &p) {
ld angle = 0;
int n = poly.size();
rep(i, n) {
Point a = poly[i], b = poly[(i + 1) % n];
if (isis_sp(Line(a, b), p))
return 1;
angle += arg((b - p) / (a - p));
}
return eq(angle, 0) ? 0 : 2;
}
//??????????????????2?????????
enum { out, on, in };
int convex_contains(const Polygon &P, const Point &p) {
const int n = P.size();
Point g = (P[0] + P[n / 3] + P[2 * n / 3]) / 3.0l; // inner-point
int a = 0, b = n;
while (a + 1 < b) { // invariant: c is in fan g-P[a]-P[b]
int c = (a + b) / 2;
if (cross(P[a] - g, P[c] - g) > 0) { // angle < 180 deg
if (cross(P[a] - g, p - g) > 0 && cross(P[c] - g, p - g) < 0)
b = c;
else
a = c;
} else {
if (cross(P[a] - g, p - g) < 0 && cross(P[c] - g, p - g) > 0)
a = c;
else
b = c;
}
}
b %= n;
if (cross(P[a] - p, P[b] - p) < 0)
return 0;
if (cross(P[a] - p, P[b] - p) > 0)
return 2;
return 1;
}
// ??????
//???????????????????????¨????????????????????§??¨???
Polygon convex_hull(vector<Point> ps) {
int n = ps.size();
int k = 0;
sort(ps.begin(), ps.end());
Polygon ch(2 * n);
for (int i = 0; i < n; ch[k++] = ps[i++])
while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0)
--k;
ch.resize(k - 1);
return ch;
}
//????????????
vector<Polygon> convex_cut(const Polygon &ps, const Line &l) {
int n = ps.size();
Polygon q;
Polygon r;
rep(i, n) {
Point a = ps[i], b = ps[(i + 1) % n];
Line m = Line(a, b);
if (ccw(l.a, l.b, a) != -1)
q.push_back(a);
if (ccw(l.a, l.b, a) != 1)
r.push_back(a);
if (ccw(l.a, l.b, a) * ccw(l.a, l.b, b) < 0 && isis_ll(l, m)) {
q.push_back(is_ll(l, m));
r.push_back(is_ll(l, m));
}
}
const vector<Polygon> polys{q, r};
return polys;
}
/* ??¢??¬??????????????? */
void add_Point(vector<Point> &ps, const Point p) {
for (Point q : ps)
if (abs(q - p) < eps)
return;
ps.push_back(p);
}
typedef int Weight;
struct edge {
int src, dst;
Weight weight;
edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
typedef vector<edge> edges;
typedef vector<edges> graph;
void add_edge(graph &g, const int from, const int to, const Weight weight) {
g[from].push_back(edge{from, to, weight});
}
graph segment_arrangement(const vector<Line> &s, const vector<Point> &p) {
int n = p.size(), m = s.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (isis_sp(s[i], p[j])) vec.emplace_back(abs(s[i].a - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
add_edge(g, from, to, static_cast<Weight>(abs(p[from] - p[to])));
}
}
return g;
}
graph sennbunn_arrangement(const vector<Line> &s) {
vector<Point> crss;
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
for (int j = i + 1; j < static_cast<int>(s.size()); ++j) {
if (isis_ss(s[i], s[j])) {
crss.push_back(is_ll2(s[i], s[j])[0]);
}
}
}
for (int i = 0; i < static_cast<int>(s.size()); ++i) {
crss.push_back(s[i][0]);
crss.push_back(s[i][1]);
}
return segment_arrangement(s, crss);
}
graph Circle_arrangement(const vector<Circle> &c, const vector<Point> &p) {
int n = p.size(), m = c.size();
graph g(n);
rep(i, m) {
vector<pair<ld, int>> vec;
rep(j, n) if (abs(abs(c[i].p - p[j]) - c[i].r) < eps)
vec.emplace_back(arg(c[i].p - p[j]), j);
sort(all(vec));
rep(j, vec.size() - 1) {
int from = vec[j].second, to = vec[j + 1].second;
ld angle = vec[j + 1].first - vec[j].first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
if (vec.size() >= 2) {
int from = vec.back().second, to = vec.front().first;
ld angle = vec.front().first - vec.back().first;
add_edge(g, from, to, static_cast<Weight>(angle * c[i].r));
}
}
return g;
}
int main() {
ld xa, ya, xb, yb, xc, yc, xd, yd;
while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
Line l(Point(xa, ya), Point(xb, yb));
Line r(Point(xc, yc), Point(xd, yd));
if (isis_ll(l, r)) {
ld ans = (dot((l[1] - l[0]), (r[1] - r[0])) / abs(l[1] - l[0])) /
abs(r[1] - r[0]);
if (ans == 0) {
cout << "YES" << endl;
continue;
}
}
cout << "NO" << endl;
}
return 0;
}
|
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 5,429
|
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) \
if (DBG) { \
cerr << #o << " " << o << endl; \
}
#define dumpc(o) \
if (DBG) { \
cerr << #o; \
for (auto &e : (o)) \
cerr << " " << e; \
cerr << endl; \
}
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)
#define all(c) c.begin(), c.end()
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-9;
signed main() {
double ax, ay, bx, by, cx, cy, dx, dy;
while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
bx -= ax;
by -= ay;
dx -= cx;
dy -= cy;
if ((bx * dx + by * dy) < EPS)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define DBG 1
#define dump(o) \
if (DBG) { \
cerr << #o << " " << o << endl; \
}
#define dumpc(o) \
if (DBG) { \
cerr << #o; \
for (auto &e : (o)) \
cerr << " " << e; \
cerr << endl; \
}
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define each(it, c) for (auto it = (c).begin(); it != (c).end(); it++)
#define all(c) c.begin(), c.end()
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
signed main() {
double ax, ay, bx, by, cx, cy, dx, dy;
while (cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy) {
bx -= ax;
by -= ay;
dx -= cx;
dy -= cy;
if (abs((bx * dx + by * dy)) < EPS)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 51, 16, 31, 2, 3, 4, 0, 23, 0, 24], ["+", 51, 16, 31, 2, 3, 4, 0, 23, 0, 25]]
| 1
| 195
|
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
double EPS = 1e-10;
void q58() {
double ax, ay, bx, by, cx, cy, dx, dy;
for (; cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;) {
if (abs((ay - by) * (cy - dy) + (cx - dx) * (ax - bx)) < EPS) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
int main() {
q58();
return 0;
}
|
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
double EPS = 1e-10;
void q58() {
double ax, ay, bx, by, cx, cy, dx, dy;
for (; cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;) {
if (abs((ay - by) * (cy - dy) + (cx - dx) * (ax - bx)) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
int main() {
q58();
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 133
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-10
#define int ll
struct vector2D {
double x, y;
};
double multiply(vector2D a, vector2D b) { return a.x * b.x + a.y * b.y; }
signed main(void) {
double x[4], y[4];
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
vector2D a, b;
a.x = x[1] - x[0];
a.y = y[1] - y[0];
b.x = x[3] - x[2];
b.y = y[3] - y[2];
if (multiply(a, b) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-10
#define int ll
struct vector2D {
double x, y;
};
double multiply(vector2D a, vector2D b) { return a.x * b.x + a.y * b.y; }
signed main(void) {
double x[4], y[4];
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
vector2D a, b;
a.x = x[1] - x[0];
a.y = y[1] - y[0];
b.x = x[3] - x[2];
b.y = y[3] - y[2];
if (fabs(multiply(a, b)) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
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, 2, 3, 4, 0, 25]]
| 1
| 294
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll
struct vector2D {
double x, y;
};
int multiply(vector2D a, vector2D b) { return a.x * b.x + a.y * b.y; }
signed main(void) {
double x[4], y[4];
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
vector2D a, b;
a.x = x[1] - x[0];
a.y = y[1] - y[0];
b.x = x[3] - x[2];
b.y = y[3] - y[2];
if (multiply(a, b) == 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-10
#define int ll
struct vector2D {
long double x, y;
};
long double multiply(vector2D a, vector2D b) { return a.x * b.x + a.y * b.y; }
signed main(void) {
long double x[4], y[4];
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
vector2D a, b;
a.x = x[1] - x[0];
a.y = y[1] - y[0];
b.x = x[3] - x[2];
b.y = y[3] - y[2];
if (multiply(a, b) == 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 0, 122, 8, 123, 0, 124, 39, 86, 0, 96], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]]
| 1
| 294
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1e9;
int main() {
vector<double> x(4);
vector<double> y(4);
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
double ax = x[1] - x[0];
double ay = y[1] - y[0];
double bx = x[3] - x[2];
double by = y[3] - y[2];
if (ax * bx + ay * by < 1e-10) {
cout << "YES" << endl;
} else
cout << "NO" << endl;
}
return 0;
}
// EOF
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1e9;
int main() {
vector<double> x(4);
vector<double> y(4);
while (cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3]) {
double ax = x[1] - x[0];
double ay = y[1] - y[0];
double bx = x[3] - x[2];
double by = y[3] - y[2];
if (fabs(ax * bx + ay * by) < 1e-10) {
cout << "YES" << endl;
} else
cout << "NO" << endl;
}
return 0;
}
// EOF
|
[["+", 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]]
| 1
| 192
|
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cctype> // require tolower, toupper
#include <cfloat>
#include <climits>
#include <cmath> // require fabs
#include <cstdio> // require scanf printf
#include <cstdlib> // require abs exit atof atoi
#include <cstring> // require memset
#include <ctime> // require srand
#include <deque>
#include <fstream> // require freopen
#include <functional>
#include <iomanip> // require setw
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // require accumulate
#include <queue>
#include <set>
#include <sstream> // require stringstream
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
#define EPS (1e-10)
#define PI (3.141592653589793238462643383279)
template <class T> struct point {
T x, y;
point &operator+=(const point &a) {
x += a.x;
y += a.y;
}
point &operator-=(const point &a) {
x -= a.x;
y -= a.y;
}
point operator+(const point &a) const { return (point){x + a.x, y + a.y}; }
point operator-(const point &a) const { return (point){x - a.x, y - a.y}; }
operator point<double>() const { return (point<double>){x, y}; }
};
template <class T> point<T> operator*(T c, const point<T> &a) {
return (point<T>){c * a.x, c * a.y};
}
point<double> &operator/=(point<double> &a, double c) {
a.x /= c;
a.y /= c;
return a;
}
template <class T> point<double> operator/(const point<T> &a, double c) {
return (point<double>){a.x / c, a.y / c};
}
// for integar number
template <class T> bool operator<(const point<T> &a, const point<T> &b) {
return (a.x < b.x || ((a.x == b.x) && (a.y < b.y)));
}
template <class T> bool operator==(const point<T> &a, const point<T> &b) {
return a.x == b.x && a.y == b.y;
}
template <class T> bool operator!=(const point<T> &a, const point<T> &b) {
return a.x != b.x || a.y != b.y;
}
// for real number
bool operator<(const point<double> &a, const point<double> &b) {
return (a.x + EPS < b.x || (abs(a.x - b.x) < EPS && (a.y + EPS < b.y)));
}
bool operator==(const point<double> &a, const point<double> &b) {
return abs(a.x - b.x) < EPS && abs(a.y - b.y) < EPS;
}
bool operator!=(const point<double> &a, const point<double> &b) {
return abs(a.x - b.x) > EPS || abs(a.y - b.y) > EPS;
}
// inner product
template <class T> T dot(const point<T> &a, const point<T> &b) {
return a.x * b.x + a.y * b.y;
}
// outer product
template <class T> T cross(const point<T> &a, const point<T> &b) {
return a.x * b.y - a.y * b.x;
}
// distance between origin(0,0) to point a
template <class T> double abs(const point<T> &a) {
return sqrt(a.x * a.x + a.y * a.y);
}
template <class T> T abs2(const point<T> &a) { return a.x * a.x + a.y * a.y; }
point<double> rot(const point<double> &a, double theta) {
return (point<double>){a.x * cos(theta) - a.y * sin(theta),
a.x * sin(theta) + a.y * cos(theta)};
}
// x 軸の正方向を基準とした場合のベクトル a の角度を [0, 2*PI) の範囲で求める
template <class T> double arg(const point<T> &a) {
double t = atan2(a.y, a.x);
return t < 0. ? t + 2. * PI : t;
}
template <class T> struct line {
point<T> a, b;
operator line<double>() const { return (line<double>){a, b}; }
};
template <class T> struct segment {
point<T> a, b;
operator line<T>() const { return (line<T>){a, b}; }
};
template <class T> struct polygon : vector<point<T>> {
polygon() {}
polygon(int n) : vector<point<T>>(n) {}
};
template <class T> struct circle {
point<T> c;
T r;
};
// 点 p を直線 L 上に射影した点を求める
template <class T> point<double> proj(const point<T> &p, const line<T> &L) {
return L.a + dot(p - L.a, L.b - L.a) / abs2(L.b - L.a) * (L.b - L.a);
}
/*
回転方向
説明
3点の位置関係を求める
(A) 座標値が整数
(B) 座標値が実数
引数
a : 点
b : 点
c : 点
戻り値
a-b-c の順に反時計回りに回転しているとき CCW
a-b-c の順に時計回りに回転しているとき CW
a-b-c が同一直線上にあるとき ON
制約
なし
計算量
O(1)
備考
2 点以上が同一の点であれば常に ON を返すことに注意
*/
/*
// (A)
enum{CCW = 1, CW = -1, ON = 0 };
template<class T>
int ccw(const point<T> &a, const point<T> &b, const point<T> &c ){
T rdir = cross (b-a, c-a );
if (rdir > 0 ) return CCW;
if (rdir < 0 ) return CW;
return ON;
}
*/
// (B)
enum { CCW = 1, CW = -1, ON = 0 };
int ccw(const point<double> &a, const point<double> &b,
const point<double> &c) {
double rdir = cross(b - a, c - a);
if (rdir > 0)
return CCW;
if (rdir < 0)
return CW;
return ON;
}
/*
点と点の距離
説明
点と点の距離を求める
dist : 距離そのもの
dist2 : 距離の二乗
引数
a : 点
b : 点
戻り値
点 a と 点 b の距離
制約
なし
計算量
O(1)
備考
*/
template <class T> double dist(const point<T> &a, const point<T> &b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
template <class T> T dist2(const point<T> &a, const point<T> &b) {
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
/*
直線と点の距離
説明
直線と点の距離を求める
dist : 距離そのもの
dist2 : 距離の二乗
引数
L : 直線
p : 点
戻り値
直線 L と点 p の距離
制約
なし
計算量
O(1)
備考
*/
template <class T> double dist(const line<T> &L, const point<T> &p) {
return abs(cross(L.b - L.a, p - L.a)) / dist(L.a, L.b);
}
/*
線分と点の距離
説明
線分と点の距離を求める
dist : 距離そのもの
dist2 : 距離の2乗
引数
S : 線分
p : 点
戻り値
線分 S と点 p の距離
計算量
O(1)
備考
dist2 は <= 0 で正しい。(ESP を使わなくてよい. )
*/
template <class T> double dist(const segment<T> &S, const point<T> &p) {
if (dot(S.b - S.a, p - S.a) <= 0)
return dist(p, S.a);
if (dot(S.a - S.b, p - S.b) <= 0)
return dist(p, S.b);
return abs(cross(S.b - S.a, p - S.a)) / dist(S.a, S.b);
}
template <class T> double dist2(const segment<T> &S, const point<T> &p) {
if (dot(S.b - S.a, p - S.a) <= 0)
return dist2(p, S.a);
if (dot(S.a - S.b, p - S.b) <= 0)
return dist2(p, S.b);
return (double)cross(S.b - S.a, p - S.a) * cross(S.b - S.a, p - S.a) /
dist(S.a, S.b);
}
/*
円と直線の交差判定
説明
円と直線が交わるかどうかを判定する
引数
C: 円
L: 直線
戻り値
交点の個数
制約
なし
計算量
O(1)
備考
*/
int intersect(const circle<double> &C, const line<double> &L) {
point<double> m = proj(C.c, L);
double d = abs(C.c - m);
if (C.r + EPS < d)
return 0;
if (C.r - EPS < d)
return 1;
return 2;
}
/*
円と線分の交差判定
説明
円と線分が交わるかどうかを判定する
(A) 座標値が整数
(B) 座標値が実数
引数
C : 円
S : 線分
戻り値
交わるなら true 交わらないなら false
制約
なし
計算量
O(1)
備考
線分が円の内部になるときは交わると判定する。
*/
// (A)
template <class T> bool intersect(const circle<T> &C, const segment<T> &S) {
return dist2(S, C.c) <= C.r * C.r;
}
// (B)
bool intersect(const circle<double> &C, const segment<double> &S) {
return dist(S, C.c) < C.r + EPS;
}
/*
三角形と点の包含判定
説明
三角形 abc が点 p を含むかどうかを判定する
引数
a : 頂点
b : 頂点
c : 頂点
戻り値
含むなら true, 含まないなら false
制約
三角形は縮退していないこと
すなわち、三点が同一直線上にないこと、(特に、どの二点も等しくないこと
計算量
O(1)
備考
三角形は CCW でも CW でもよい
点が三角形の境界になるときは含むと判定する
Verified: AOJ 0143 Altair and Vega
*/
template <class T>
bool cover(const point<T> &a, const point<T> &b, const point<T> &c,
const point<T> &p) {
int d1 = ccw(p, a, b);
int d2 = ccw(p, b, c);
int d3 = ccw(p, c, a);
return !((d1 == CCW && d2 == CW) || (d1 == CCW && d3 == CW) ||
(d2 == CCW && d3 == CW) || (d1 == CW && d2 == CCW) ||
(d1 == CW && d3 == CCW) || (d2 == CW && d3 == CCW));
}
/*
内接円の半径
説明
辺長がそれぞれ、a, b, c である三角形の内接円の半径を求める
引数
a: 辺長
b: 辺長
c: 辺長
戻り値
内接円の半径
制約
a >= 0, b >= 0, c >= 0
a < b + c, c < c + a, c < a + b (三角形の成立条件)
計算量
O(1)
備考
三角形が縮退しているときは nan を返すかもしれない
*/
double inradius(double a, double b, double c) {
return sqrt((b + c - a) * (c + a - b) * (a + b - c) / (a + b + c)) / 2.;
}
/*
外接円
説明
三角形 abc の外接円を求める
引数
a: 頂点
b: 頂点
c: 頂点
戻り値
外接円
制約
a, b, c は同一直線上にないこと
計算量
O(1)
備考
a, b, c が同一直線上にあるときは外接円は存在しない
頂点が整数座標のとき、外心の座標と半径の二乗は有理数となる
Verified: AOJ 0010 Circumscribed Circle of a Triangle
*/
circle<double> circumcircle(const point<double> &a, point<double> b,
point<double> c) {
b -= a;
c -= a;
double A2 = abs2(b - c), B2 = abs2(b), C2 = abs2(c);
double d = 2 * cross(b, c);
double nx = c.y * B2 - b.y * C2;
double ny = b.x * C2 - c.x * B2;
double r2 = A2 * B2 * C2 / (d * d);
return (circle<double>){a + (point<double>){nx / d, ny / d}, sqrt(r2)};
}
/*
外接円の半径
説明
辺長がそれぞれ a, b, c である三角形の外接円の半径を求める
引数
a : 辺長
b : 辺長
c : 辺長
戻り値
外接円の半径
制約
a >= 0, b >= 0, c >= 0
a < b + c, b < c + a, c < a + b (三角形の成立条件)
計算量
O(1)
備考
三角形が縮退しているときは nan を返すかもしれない
Verified: AOJ 0010 Circumscribed Circle of a Triangle
*/
double circumradius(double a, double b, double c) {
return a * b * c /
sqrt((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c));
}
/*
反時計回りに変換
説明
多角形の頂点の順番が CW であれば CCW に変換する
元々 CCW であれば何もしない
(A) 座標値が整数
(B) 座標値が実数
引数
G : 多角形
戻り値
なし(引数 G が更新される)
制約
G は単純
計算量
O(n)
備考
単純多角形とは自己交差しない多角形のこと
Verified: AOJ 0035: Is it Convex?
*/
// (A)
template <class T> void to_ccw(polygon<T> &G) {
int n = G.size();
T A = 0;
rep(i, n) A += cross(G[i], G[(i + 1) % n]);
if (A < 0)
reverse(ALL(G));
}
// (B)
void to_ccw(polygon<double> &G) {
int n = G.size();
double A = 0.;
rep(i, n) A += cross(G[i], G[(i + 1) % n]);
if (A < -EPS)
reverse(ALL(G));
}
/*
凸性判定
説明
多角形が凸かどうかを判定する
引数
G : 多角形
戻り値
G は単調かつ頂点の順番が CCW で与えられていること
計算量
O(n)
備考
Verified: AOJ 0035: Is it Convex?
*/
template <class T> bool is_convex(const polygon<T> &G) {
int n = G.size();
rep(i, n) if (ccw(G[i], G[(i + 1) % n], G[(i + 2) % n]) == CW) return false;
return true;
}
/*
線分と線分の交差判定
説明
線分と線分が交わるかどうかを判定する
(A) 座標値が整数
(B) 座標値が実数
引数
S1 : 線分
S2 : 線分
戻り値
交わるなら true, 交わらないなら false
制約
なし
計算量
O(1)
備考
bounding box によるラフチェックは必要。( ccw
による判定だと、二線分が同一直線上にあるとき間違う。)
*/
// (A)
template <class T> bool intersect(const segment<T> &S1, const segment<T> &S2) {
if (max(S1.a.x, S1.b.x) < min(S2.a.x, S2.b.x) ||
max(S1.a.y, S1.b.y) < min(S2.a.y, S2.b.y) ||
max(S2.a.x, S2.b.x) < min(S1.a.x, S1.b.x) ||
max(S2.a.y, S2.b.y) < min(S1.a.y, S1.b.y))
return false;
return ccw(S1.a, S1.b, S2.a) * ccw(S1.a, S1.b, S2.b) <= 0 &&
ccw(S2.a, S2.b, S1.a) * ccw(S2.a, S2.b, S1.b) <= 0;
}
/*
多角形と線分の交差判定
説明
多角形と線分が交わるかどうかを判定する
引数
G : 多角形
S : 線分
戻り値
交わるなら true, 交わらないなら false
制約
なし
計算量
O(n)
備考
G は凸でなくていい。
G は境界を含む
S が G の内部にあるときは交わると判定する
*/
template <class T> bool intersect(const polygon<T> &G, const segment<T> &S) {
int n = G.size();
if (cover(G, S.a) || cover(G, S.b))
return true;
rep(i, n) if (intersect((segment<T>){G[i], G[(i + 1) % n]}, S)) return true;
return false;
}
int main() {
// cut here before submit
// freopen ("testcase.0058", "r", stdin );
ios_base::sync_with_stdio(0);
string str = "";
while (getline(cin, str)) {
stringstream ss(str);
point<double> p[4];
rep(i, 4) ss >> p[i].x >> p[i].y;
if (dot(p[1] - p[0], p[3] - p[2]) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
} // end if
} // end loop
// printf ("%d\n", res );
return 0;
}
|
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cctype> // require tolower, toupper
#include <cfloat>
#include <climits>
#include <cmath> // require fabs
#include <cstdio> // require scanf printf
#include <cstdlib> // require abs exit atof atoi
#include <cstring> // require memset
#include <ctime> // require srand
#include <deque>
#include <fstream> // require freopen
#include <functional>
#include <iomanip> // require setw
#include <iostream>
#include <limits>
#include <map>
#include <numeric> // require accumulate
#include <queue>
#include <set>
#include <sstream> // require stringstream
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
#define EPS (1e-10)
#define PI (3.141592653589793238462643383279)
template <class T> struct point {
T x, y;
point &operator+=(const point &a) {
x += a.x;
y += a.y;
}
point &operator-=(const point &a) {
x -= a.x;
y -= a.y;
}
point operator+(const point &a) const { return (point){x + a.x, y + a.y}; }
point operator-(const point &a) const { return (point){x - a.x, y - a.y}; }
operator point<double>() const { return (point<double>){x, y}; }
};
template <class T> point<T> operator*(T c, const point<T> &a) {
return (point<T>){c * a.x, c * a.y};
}
point<double> &operator/=(point<double> &a, double c) {
a.x /= c;
a.y /= c;
return a;
}
template <class T> point<double> operator/(const point<T> &a, double c) {
return (point<double>){a.x / c, a.y / c};
}
// for integar number
template <class T> bool operator<(const point<T> &a, const point<T> &b) {
return (a.x < b.x || ((a.x == b.x) && (a.y < b.y)));
}
template <class T> bool operator==(const point<T> &a, const point<T> &b) {
return a.x == b.x && a.y == b.y;
}
template <class T> bool operator!=(const point<T> &a, const point<T> &b) {
return a.x != b.x || a.y != b.y;
}
// for real number
bool operator<(const point<double> &a, const point<double> &b) {
return (a.x + EPS < b.x || (abs(a.x - b.x) < EPS && (a.y + EPS < b.y)));
}
bool operator==(const point<double> &a, const point<double> &b) {
return abs(a.x - b.x) < EPS && abs(a.y - b.y) < EPS;
}
bool operator!=(const point<double> &a, const point<double> &b) {
return abs(a.x - b.x) > EPS || abs(a.y - b.y) > EPS;
}
// inner product
template <class T> T dot(const point<T> &a, const point<T> &b) {
return a.x * b.x + a.y * b.y;
}
// outer product
template <class T> T cross(const point<T> &a, const point<T> &b) {
return a.x * b.y - a.y * b.x;
}
// distance between origin(0,0) to point a
template <class T> double abs(const point<T> &a) {
return sqrt(a.x * a.x + a.y * a.y);
}
template <class T> T abs2(const point<T> &a) { return a.x * a.x + a.y * a.y; }
point<double> rot(const point<double> &a, double theta) {
return (point<double>){a.x * cos(theta) - a.y * sin(theta),
a.x * sin(theta) + a.y * cos(theta)};
}
// x 軸の正方向を基準とした場合のベクトル a の角度を [0, 2*PI) の範囲で求める
template <class T> double arg(const point<T> &a) {
double t = atan2(a.y, a.x);
return t < 0. ? t + 2. * PI : t;
}
template <class T> struct line {
point<T> a, b;
operator line<double>() const { return (line<double>){a, b}; }
};
template <class T> struct segment {
point<T> a, b;
operator line<T>() const { return (line<T>){a, b}; }
};
template <class T> struct polygon : vector<point<T>> {
polygon() {}
polygon(int n) : vector<point<T>>(n) {}
};
template <class T> struct circle {
point<T> c;
T r;
};
// 点 p を直線 L 上に射影した点を求める
template <class T> point<double> proj(const point<T> &p, const line<T> &L) {
return L.a + dot(p - L.a, L.b - L.a) / abs2(L.b - L.a) * (L.b - L.a);
}
/*
回転方向
説明
3点の位置関係を求める
(A) 座標値が整数
(B) 座標値が実数
引数
a : 点
b : 点
c : 点
戻り値
a-b-c の順に反時計回りに回転しているとき CCW
a-b-c の順に時計回りに回転しているとき CW
a-b-c が同一直線上にあるとき ON
制約
なし
計算量
O(1)
備考
2 点以上が同一の点であれば常に ON を返すことに注意
*/
/*
// (A)
enum{CCW = 1, CW = -1, ON = 0 };
template<class T>
int ccw(const point<T> &a, const point<T> &b, const point<T> &c ){
T rdir = cross (b-a, c-a );
if (rdir > 0 ) return CCW;
if (rdir < 0 ) return CW;
return ON;
}
*/
// (B)
enum { CCW = 1, CW = -1, ON = 0 };
int ccw(const point<double> &a, const point<double> &b,
const point<double> &c) {
double rdir = cross(b - a, c - a);
if (rdir > 0)
return CCW;
if (rdir < 0)
return CW;
return ON;
}
/*
点と点の距離
説明
点と点の距離を求める
dist : 距離そのもの
dist2 : 距離の二乗
引数
a : 点
b : 点
戻り値
点 a と 点 b の距離
制約
なし
計算量
O(1)
備考
*/
template <class T> double dist(const point<T> &a, const point<T> &b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
template <class T> T dist2(const point<T> &a, const point<T> &b) {
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
/*
直線と点の距離
説明
直線と点の距離を求める
dist : 距離そのもの
dist2 : 距離の二乗
引数
L : 直線
p : 点
戻り値
直線 L と点 p の距離
制約
なし
計算量
O(1)
備考
*/
template <class T> double dist(const line<T> &L, const point<T> &p) {
return abs(cross(L.b - L.a, p - L.a)) / dist(L.a, L.b);
}
/*
線分と点の距離
説明
線分と点の距離を求める
dist : 距離そのもの
dist2 : 距離の2乗
引数
S : 線分
p : 点
戻り値
線分 S と点 p の距離
計算量
O(1)
備考
dist2 は <= 0 で正しい。(ESP を使わなくてよい. )
*/
template <class T> double dist(const segment<T> &S, const point<T> &p) {
if (dot(S.b - S.a, p - S.a) <= 0)
return dist(p, S.a);
if (dot(S.a - S.b, p - S.b) <= 0)
return dist(p, S.b);
return abs(cross(S.b - S.a, p - S.a)) / dist(S.a, S.b);
}
template <class T> double dist2(const segment<T> &S, const point<T> &p) {
if (dot(S.b - S.a, p - S.a) <= 0)
return dist2(p, S.a);
if (dot(S.a - S.b, p - S.b) <= 0)
return dist2(p, S.b);
return (double)cross(S.b - S.a, p - S.a) * cross(S.b - S.a, p - S.a) /
dist(S.a, S.b);
}
/*
円と直線の交差判定
説明
円と直線が交わるかどうかを判定する
引数
C: 円
L: 直線
戻り値
交点の個数
制約
なし
計算量
O(1)
備考
*/
int intersect(const circle<double> &C, const line<double> &L) {
point<double> m = proj(C.c, L);
double d = abs(C.c - m);
if (C.r + EPS < d)
return 0;
if (C.r - EPS < d)
return 1;
return 2;
}
/*
円と線分の交差判定
説明
円と線分が交わるかどうかを判定する
(A) 座標値が整数
(B) 座標値が実数
引数
C : 円
S : 線分
戻り値
交わるなら true 交わらないなら false
制約
なし
計算量
O(1)
備考
線分が円の内部になるときは交わると判定する。
*/
// (A)
template <class T> bool intersect(const circle<T> &C, const segment<T> &S) {
return dist2(S, C.c) <= C.r * C.r;
}
// (B)
bool intersect(const circle<double> &C, const segment<double> &S) {
return dist(S, C.c) < C.r + EPS;
}
/*
三角形と点の包含判定
説明
三角形 abc が点 p を含むかどうかを判定する
引数
a : 頂点
b : 頂点
c : 頂点
戻り値
含むなら true, 含まないなら false
制約
三角形は縮退していないこと
すなわち、三点が同一直線上にないこと、(特に、どの二点も等しくないこと
計算量
O(1)
備考
三角形は CCW でも CW でもよい
点が三角形の境界になるときは含むと判定する
Verified: AOJ 0143 Altair and Vega
*/
template <class T>
bool cover(const point<T> &a, const point<T> &b, const point<T> &c,
const point<T> &p) {
int d1 = ccw(p, a, b);
int d2 = ccw(p, b, c);
int d3 = ccw(p, c, a);
return !((d1 == CCW && d2 == CW) || (d1 == CCW && d3 == CW) ||
(d2 == CCW && d3 == CW) || (d1 == CW && d2 == CCW) ||
(d1 == CW && d3 == CCW) || (d2 == CW && d3 == CCW));
}
/*
内接円の半径
説明
辺長がそれぞれ、a, b, c である三角形の内接円の半径を求める
引数
a: 辺長
b: 辺長
c: 辺長
戻り値
内接円の半径
制約
a >= 0, b >= 0, c >= 0
a < b + c, c < c + a, c < a + b (三角形の成立条件)
計算量
O(1)
備考
三角形が縮退しているときは nan を返すかもしれない
*/
double inradius(double a, double b, double c) {
return sqrt((b + c - a) * (c + a - b) * (a + b - c) / (a + b + c)) / 2.;
}
/*
外接円
説明
三角形 abc の外接円を求める
引数
a: 頂点
b: 頂点
c: 頂点
戻り値
外接円
制約
a, b, c は同一直線上にないこと
計算量
O(1)
備考
a, b, c が同一直線上にあるときは外接円は存在しない
頂点が整数座標のとき、外心の座標と半径の二乗は有理数となる
Verified: AOJ 0010 Circumscribed Circle of a Triangle
*/
circle<double> circumcircle(const point<double> &a, point<double> b,
point<double> c) {
b -= a;
c -= a;
double A2 = abs2(b - c), B2 = abs2(b), C2 = abs2(c);
double d = 2 * cross(b, c);
double nx = c.y * B2 - b.y * C2;
double ny = b.x * C2 - c.x * B2;
double r2 = A2 * B2 * C2 / (d * d);
return (circle<double>){a + (point<double>){nx / d, ny / d}, sqrt(r2)};
}
/*
外接円の半径
説明
辺長がそれぞれ a, b, c である三角形の外接円の半径を求める
引数
a : 辺長
b : 辺長
c : 辺長
戻り値
外接円の半径
制約
a >= 0, b >= 0, c >= 0
a < b + c, b < c + a, c < a + b (三角形の成立条件)
計算量
O(1)
備考
三角形が縮退しているときは nan を返すかもしれない
Verified: AOJ 0010 Circumscribed Circle of a Triangle
*/
double circumradius(double a, double b, double c) {
return a * b * c /
sqrt((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c));
}
/*
反時計回りに変換
説明
多角形の頂点の順番が CW であれば CCW に変換する
元々 CCW であれば何もしない
(A) 座標値が整数
(B) 座標値が実数
引数
G : 多角形
戻り値
なし(引数 G が更新される)
制約
G は単純
計算量
O(n)
備考
単純多角形とは自己交差しない多角形のこと
Verified: AOJ 0035: Is it Convex?
*/
// (A)
template <class T> void to_ccw(polygon<T> &G) {
int n = G.size();
T A = 0;
rep(i, n) A += cross(G[i], G[(i + 1) % n]);
if (A < 0)
reverse(ALL(G));
}
// (B)
void to_ccw(polygon<double> &G) {
int n = G.size();
double A = 0.;
rep(i, n) A += cross(G[i], G[(i + 1) % n]);
if (A < -EPS)
reverse(ALL(G));
}
/*
凸性判定
説明
多角形が凸かどうかを判定する
引数
G : 多角形
戻り値
G は単調かつ頂点の順番が CCW で与えられていること
計算量
O(n)
備考
Verified: AOJ 0035: Is it Convex?
*/
template <class T> bool is_convex(const polygon<T> &G) {
int n = G.size();
rep(i, n) if (ccw(G[i], G[(i + 1) % n], G[(i + 2) % n]) == CW) return false;
return true;
}
/*
線分と線分の交差判定
説明
線分と線分が交わるかどうかを判定する
(A) 座標値が整数
(B) 座標値が実数
引数
S1 : 線分
S2 : 線分
戻り値
交わるなら true, 交わらないなら false
制約
なし
計算量
O(1)
備考
bounding box によるラフチェックは必要。( ccw
による判定だと、二線分が同一直線上にあるとき間違う。)
*/
// (A)
template <class T> bool intersect(const segment<T> &S1, const segment<T> &S2) {
if (max(S1.a.x, S1.b.x) < min(S2.a.x, S2.b.x) ||
max(S1.a.y, S1.b.y) < min(S2.a.y, S2.b.y) ||
max(S2.a.x, S2.b.x) < min(S1.a.x, S1.b.x) ||
max(S2.a.y, S2.b.y) < min(S1.a.y, S1.b.y))
return false;
return ccw(S1.a, S1.b, S2.a) * ccw(S1.a, S1.b, S2.b) <= 0 &&
ccw(S2.a, S2.b, S1.a) * ccw(S2.a, S2.b, S1.b) <= 0;
}
/*
多角形と線分の交差判定
説明
多角形と線分が交わるかどうかを判定する
引数
G : 多角形
S : 線分
戻り値
交わるなら true, 交わらないなら false
制約
なし
計算量
O(n)
備考
G は凸でなくていい。
G は境界を含む
S が G の内部にあるときは交わると判定する
*/
template <class T> bool intersect(const polygon<T> &G, const segment<T> &S) {
int n = G.size();
if (cover(G, S.a) || cover(G, S.b))
return true;
rep(i, n) if (intersect((segment<T>){G[i], G[(i + 1) % n]}, S)) return true;
return false;
}
int main() {
// cut here before submit
// freopen ("testcase.0058", "r", stdin );
ios_base::sync_with_stdio(0);
string str = "";
while (getline(cin, str)) {
stringstream ss(str);
point<double> p[4];
rep(i, 4) ss >> p[i].x >> p[i].y;
if (abs(dot(p[1] - p[0], p[3] - p[2])) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
} // end if
} // end loop
// printf ("%d\n", res );
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, 2, 3, 4, 0, 25]]
| 1
| 2,916
|
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
class Point {
public:
double y, x;
Point() {}
Point(double y0, double x0) {
y = y0;
x = x0;
}
Point operator-(const Point &p) const { return Point(y - p.y, x - p.x); }
double dot(const Point &p) const { return y * p.y + x * p.x; }
};
int main() {
for (;;) {
Point a, b, c, d;
if (!(cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y))
return 0;
a = a - b;
c = c - d;
if (a.dot(c) < 1.0e-10)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
class Point {
public:
double y, x;
Point() {}
Point(double y0, double x0) {
y = y0;
x = x0;
}
Point operator-(const Point &p) const { return Point(y - p.y, x - p.x); }
double dot(const Point &p) const { return y * p.y + x * p.x; }
};
int main() {
for (;;) {
Point a, b, c, d;
if (!(cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y))
return 0;
a = a - b;
c = c - d;
if (a.dot(c) == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 227
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v, i) (v).erase(remove(all(v), i), (v).end())
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define each(c, it) \
for (typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define debug(x) cerr << #x << " = " << (x) << endl;
#define LINE cerr << "LINE: " << __LINE__ << endl;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
template <class T> void preview(T a, T b) {
for (T it = a; it != b; ++it)
cerr << *it << " ";
cerr << endl;
}
const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;
int main() {
double ax, ay, bx, by, cx, cy, dx, dy;
for (; cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;) {
cout << ((bx - ax) * (dx - cx) + (by - ay) * (dy - cy) < EPS ? "YES" : "NO")
<< endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v, i) (v).erase(remove(all(v), i), (v).end())
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define each(c, it) \
for (typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define debug(x) cerr << #x << " = " << (x) << endl;
#define LINE cerr << "LINE: " << __LINE__ << endl;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
template <class T> void preview(T a, T b) {
for (T it = a; it != b; ++it)
cerr << *it << " ";
cerr << endl;
}
const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;
int main() {
double ax, ay, bx, by, cx, cy, dx, dy;
for (; cin >> ax >> ay >> bx >> by >> cx >> cy >> dx >> dy;) {
cout << (fabs((bx - ax) * (dx - cx) + (by - ay) * (dy - cy)) < EPS ? "YES"
: "NO")
<< endl;
}
return 0;
}
|
[["+", 12, 23, 0, 41, 15, 16, 31, 2, 63, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 12, 16, 12, 23, 0, 25]]
| 1
| 305
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
int main() {
double eps = 10e-7;
double xA, yA, xB, yB, xC, yC, xD, yD;
while (~scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xA, &yA, &xB, &yB, &xC, &yC,
&xD, &yD)) {
if ((xB - xA) * (xD - xC) + (yB - yA) * (yD - yC) < eps) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
int main() {
double eps = 10e-7;
double xA, yA, xB, yB, xC, yC, xD, yD;
while (~scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &xA, &yA, &xB, &yB, &xC, &yC,
&xD, &yD)) {
if ((xB - xA) * (xD - xC) + (yB - yA) * (yD - yC) == 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 158
|
#include <cmath>
#include <iostream>
using namespace std;
namespace geo {
const double EPS = 1e-10;
class Point {
public:
double x, y;
Point(double _x = 0.0, double _y = 0.0) : x(_x), y(_y) {}
inline double abs() const { return sqrt(x * x + y * y); }
// 内積
inline double dot(const Point &p) const { return (x * p.x + y * p.y); }
// 外積
inline double cross(const Point &p) const { return (x * p.y - y + p.x); }
// 直交
inline bool orthogonal(const Point &p) const {
if (dot(p) < EPS)
return true;
return false;
}
// 平行
inline bool parallel(const Point &p) const {
if (cross(p) < EPS)
return true;
return false;
}
Point operator+(const Point &p) const { return Point(x + p.x, y - p.y); }
Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
Point operator=(const Point &p) {
x = p.x;
y = p.y;
}
bool operator==(const Point &p) const {
if ((*this - p).abs() < EPS)
return true;
return false;
}
};
} // namespace geo
using namespace geo;
int main() {
double xA, yA, xB, yB, xC, yC, xD, yD;
while (cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD) {
Point AB(xA - xB, yA - yB), CD(xC - xD, yC - yD);
if (AB.orthogonal(CD))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
namespace geo {
const double EPS = 1e-10;
class Point {
public:
double x, y;
Point(double _x = 0.0, double _y = 0.0) : x(_x), y(_y) {}
inline double abs() const { return sqrt(x * x + y * y); }
// 内積
inline double dot(const Point &p) const { return (x * p.x + y * p.y); }
// 外積
inline double cross(const Point &p) const { return (x * p.y - y + p.x); }
// 直交
inline bool orthogonal(const Point &p) const {
if (dot(p) == 0.0)
return true;
return false;
}
// 平行
inline bool parallel(const Point &p) const {
if (cross(p) < EPS)
return true;
return false;
}
Point operator+(const Point &p) const { return Point(x + p.x, y - p.y); }
Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
Point operator=(const Point &p) {
x = p.x;
y = p.y;
}
bool operator==(const Point &p) const {
if ((*this - p).abs() < EPS)
return true;
return false;
}
};
} // namespace geo
using namespace geo;
int main() {
double xA, yA, xB, yB, xC, yC, xD, yD;
while (cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD) {
Point AB(xA - xB, yA - yB), CD(xC - xD, yC - yD);
if (AB.orthogonal(CD))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 400
|
#include <iostream>
using namespace std;
struct P {
double x;
double y;
};
int main() {
P a, b, c, d;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y) {
P v, w;
v.x = a.x - b.x;
v.y = a.y - b.y;
w.x = c.x - d.x;
w.y = c.y - d.y;
if (v.x * w.x + w.x * w.y == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
struct P {
double x;
double y;
};
int main() {
P a, b, c, d;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y) {
P v, w;
v.x = a.x - b.x;
v.y = a.y - b.y;
w.x = c.x - d.x;
w.y = c.y - d.y;
if (v.x * w.x + v.y * w.y == 0)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 51, 16, 31, 16, 12, 16, 31, 118, 28, 22], ["+", 51, 16, 31, 16, 12, 16, 31, 118, 28, 22], ["-", 51, 16, 31, 16, 12, 16, 31, 118, 119, 120], ["+", 51, 16, 31, 16, 12, 16, 31, 118, 119, 120]]
| 1
| 163
|
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e10;
struct Point {
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
double distance(const Point &o) const {
return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
}
Point operator+(const Point &o) const { return Point(x + o.x, y + o.y); }
Point operator-(const Point &o) const { return Point(x - o.x, y - o.y); }
Point operator*(const double m) const { return Point(x * m, y * m); }
Point operator/(const double d) const { return Point(x / d, y / d); }
bool operator==(const Point &o) const {
return (x - o.x < EPS && y - o.y < EPS);
}
// 外積
double cross(const Point &o) const { return x * o.y - y * o.x; }
// 内積
double dot(const Point &o) const { return x * o.x + y * o.y; }
// ベクトルがx軸となす角
double atan() const { return atan2(y, x); }
// ベクトルの長さの二乗
double norm() const { return dot(*this); }
double abs() const { return fabs(x * x + y * y); }
};
int main() {
Point a, b, c, d;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y) {
Point ab(b - a), cd(d - c);
if (ab.dot(cd) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e10;
struct Point {
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
double distance(const Point &o) const {
return sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y));
}
Point operator+(const Point &o) const { return Point(x + o.x, y + o.y); }
Point operator-(const Point &o) const { return Point(x - o.x, y - o.y); }
Point operator*(const double m) const { return Point(x * m, y * m); }
Point operator/(const double d) const { return Point(x / d, y / d); }
bool operator==(const Point &o) const {
return (x - o.x < EPS && y - o.y < EPS);
}
// 外積
double cross(const Point &o) const { return x * o.y - y * o.x; }
// 内積
double dot(const Point &o) const { return x * o.x + y * o.y; }
// ベクトルがx軸となす角
double atan() const { return atan2(y, x); }
// ベクトルの長さの二乗
double norm() const { return dot(*this); }
double abs() const { return fabs(x * x + y * y); }
};
int main() {
Point a, b, c, d;
while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y) {
Point ab(b - a), cd(d - c);
if (fabs(ab.dot(cd)) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
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, 2, 3, 4, 0, 25]]
| 1
| 439
|
#include <iostream>
using namespace std;
typedef struct Point {
double x, y;
};
int main() {
Point p[4];
double x[2], y[2];
while (cin >> p[0].x) {
cin >> p[0].y;
for (int i = 1; i < 4; i++) {
cin >> p[i].x;
cin >> p[i].y;
}
x[0] = p[0].x - p[1].x;
x[1] = p[2].x - p[3].x;
y[0] = p[0].y - p[1].y;
y[1] = p[2].y - p[3].y;
if (x[0] * x[1] + y[0] * y[1] <= 1e-3) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
/*
Sample Input
1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0
0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0
10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1
2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3
Output for the Sample Input
YES
NO
NO
YES
*/
|
#include <iostream>
using namespace std;
typedef struct Point {
double x, y;
};
int main() {
Point p[4];
double x[2], y[2];
while (cin >> p[0].x) {
cin >> p[0].y;
for (int i = 1; i < 4; i++) {
cin >> p[i].x;
cin >> p[i].y;
}
x[0] = p[0].x - p[1].x;
x[1] = p[2].x - p[3].x;
y[0] = p[0].y - p[1].y;
y[1] = p[2].y - p[3].y;
if (x[0] * x[1] + y[0] * y[1] == 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
/*
Sample Input
1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0
0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0
10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1
2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3
Output for the Sample Input
YES
NO
NO
YES
*/
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 222
|
#include <cmath>
#include <iostream>
using namespace std;
typedef pair<double, double> P;
void solve() {
P p[4];
while (cin >> p[0].first >> p[0].second) {
for (int i = 1; i < 4; ++i) {
cin >> p[i].first >> p[i].second;
}
if ((p[1].first - p[0].first) * (p[3].first - p[2].first) +
(p[1].second - p[0].second) * (p[3].second - p[2].second) <
1e-12) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
int main() {
solve();
return (0);
}
|
#include <cmath>
#include <iostream>
using namespace std;
typedef pair<double, double> P;
void solve() {
P p[4];
while (cin >> p[0].first >> p[0].second) {
for (int i = 1; i < 4; ++i) {
cin >> p[i].first >> p[i].second;
}
if (fabs((p[1].first - p[0].first) * (p[3].first - p[2].first) +
(p[1].second - p[0].second) * (p[3].second - p[2].second)) <
1e-12) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}
int main() {
solve();
return (0);
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 2, 63, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 16, 12, 16, 12, 23, 0, 25]]
| 1
| 185
|
#include <iostream>
using namespace std;
double xa, ya, xb, yb, xc, yc, xd, yd;
int main() {
while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
((xb - xa) * (xd - xc) + (yb - ya) * (yd - yc)) ? cout << "YES" << endl
: cout << "NO" << endl;
}
}
|
#include <iostream>
using namespace std;
double xa, ya, xb, yb, xc, yc, xd, yd;
int main() {
while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
!((xb - xa) * (xd - xc) + (yb - ya) * (yd - yc)) ? cout << "YES" << endl
: cout << "NO" << endl;
}
}
|
[["+", 8, 9, 0, 1, 0, 41, 15, 91, 17, 111]]
| 1
| 93
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toStr(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, (n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
#include <complex>
typedef complex<double> P;
double dot(P a, P b) { return real(conj(a) * b); }
int main() {
double x1, y1, x2, y2, x3, y3, x4, y4;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4) {
P p1(x2 - x1, y2 - y1);
P p2(x4 - x3, y4 - y3);
if (abs(dot(p1, p2)) < EPS) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
return 0;
}
|
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toStr(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, (n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
#include <complex>
typedef complex<double> P;
double dot(P a, P b) { return real(conj(a) * b); }
int main() {
double x1, y1, x2, y2, x3, y3, x4, y4;
while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4) {
P p1(x2 - x1, y2 - y1);
P p2(x4 - x3, y4 - y3);
if (abs(dot(p1, p2)) < EPS) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 311
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-6
#define F first
#define S second
static const double PI = 6 * asin(0.5);
typedef pair<double, double> P;
typedef complex<double> CP;
typedef long long ll;
int main() {
P a, b, c, d;
while (cin >> a.F >> a.S >> b.F >> b.S >> c.F >> c.S >> d.F >> d.S) {
P x, y;
x.F = b.F - a.F;
x.S = b.S - a.S;
y.F = d.F - c.F;
y.S = d.S - c.S;
if (x.F * y.F + x.S * y.S <= EPS)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define EPS 1e-11
#define F first
#define S second
static const double PI = 6 * asin(0.5);
typedef pair<double, double> P;
typedef complex<double> CP;
typedef long long ll;
int main() {
P a, b, c, d;
while (cin >> a.F >> a.S >> b.F >> b.S >> c.F >> c.S >> d.F >> d.S) {
P x, y;
x.F = b.F - a.F;
x.S = b.S - a.S;
y.F = d.F - c.F;
y.S = d.S - c.S;
if (fabs(x.F * y.F + x.S * y.S) <= EPS)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 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]]
| 1
| 229
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// define eps
double EPS = 1e-10;
// Point2D & Vector2D
struct Point2D {
double x, y;
Point2D(double a = 0, double b = 0) : x(a), y(b) {}
};
typedef Point2D Vector2D;
// Point2D's and Vector2D's operator
Point2D operator+(Point2D a, Point2D b) {
return Point2D(a.x + b.x, a.y + b.y);
}
Point2D operator-(Point2D a, Point2D b) {
return Point2D(a.x - b.x, a.y - b.y);
}
Point2D operator*(Point2D a, double d) { return Point2D(a.x * d, a.y * d); }
Point2D operator/(Point2D a, double d) { return Point2D(a.x / d, a.y / d); }
bool operator<(const Point2D &a, const Point2D &b) {
return a.x != b.x ? a.x < b.x : a.y < b.y;
}
bool operator>(const Point2D &a, const Point2D &b) {
return b.x != a.x ? b.x < a.x : b.y < a.y;
}
bool operator==(const Point2D &a, const Point2D &b) {
return fabs(a.x - b.x) < EPS && fabs(a.y - b.y) < EPS;
}
// basic function
double norm(Point2D a) { return a.x * a.x + a.y * a.y; }
double dot2D(const Vector2D &a, const Vector2D &b) {
return a.x * b.x + a.y * b.y;
}
double cross2D(const Vector2D &a, const Vector2D &b) {
return a.x * b.y - a.y * b.x;
}
double dist2D(const Point2D &a, const Point2D &b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
bool is_vertical(const Vector2D &a, const Vector2D &b) {
return dot2D(a, b) < EPS;
}
bool is_parrallel(const Vector2D &a, const Vector2D &b) {
return fabs(cross2D(a, b)) < EPS;
}
int main() {
Point2D A, B, C, D;
while (cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y) {
Vector2D AB = B - A;
Vector2D CD = D - C;
if (is_vertical(AB, CD))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// define eps
double EPS = 1e-10;
// Point2D & Vector2D
struct Point2D {
double x, y;
Point2D(double a = 0, double b = 0) : x(a), y(b) {}
};
typedef Point2D Vector2D;
// Point2D's and Vector2D's operator
Point2D operator+(Point2D a, Point2D b) {
return Point2D(a.x + b.x, a.y + b.y);
}
Point2D operator-(Point2D a, Point2D b) {
return Point2D(a.x - b.x, a.y - b.y);
}
Point2D operator*(Point2D a, double d) { return Point2D(a.x * d, a.y * d); }
Point2D operator/(Point2D a, double d) { return Point2D(a.x / d, a.y / d); }
bool operator<(const Point2D &a, const Point2D &b) {
return a.x != b.x ? a.x < b.x : a.y < b.y;
}
bool operator>(const Point2D &a, const Point2D &b) {
return b.x != a.x ? b.x < a.x : b.y < a.y;
}
bool operator==(const Point2D &a, const Point2D &b) {
return fabs(a.x - b.x) < EPS && fabs(a.y - b.y) < EPS;
}
// basic function
double norm(Point2D a) { return a.x * a.x + a.y * a.y; }
double dot2D(const Vector2D &a, const Vector2D &b) {
return a.x * b.x + a.y * b.y;
}
double cross2D(const Vector2D &a, const Vector2D &b) {
return a.x * b.y - a.y * b.x;
}
double dist2D(const Point2D &a, const Point2D &b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
bool is_vertical(const Vector2D &a, const Vector2D &b) {
return fabs(dot2D(a, b)) < EPS;
}
bool is_parrallel(const Vector2D &a, const Vector2D &b) {
return fabs(cross2D(a, b)) < EPS;
}
int main() {
Point2D A, B, C, D;
while (cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y) {
Vector2D AB = B - A;
Vector2D CD = D - C;
if (is_vertical(AB, CD))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 37, 0, 16, 31, 2, 63, 22], ["+", 0, 37, 0, 16, 31, 2, 3, 4, 0, 24], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
| 1
| 625
|
#!ruby -n
l=$_.split.map(&:to_f)
puts ((l[3]-l[1])*(l[7]-l[5])+(l[2]-l[0])*(l[6]-l[4])<1e-8)? 'YES': 'NO'
|
#!ruby -n
l=$_.split.map(&:to_f)
puts ((l[3]-l[1])*(l[7]-l[5])+(l[2]-l[0])*(l[6]-l[4])).abs<1e-12? 'YES': 'NO'
|
[["-", 3, 4, 0, 754, 15, 739, 0, 738, 17, 18], ["-", 3, 4, 0, 754, 15, 739, 0, 738, 12, 531], ["+", 3, 4, 0, 754, 15, 738, 31, 652, 17, 131], ["+", 3, 4, 0, 754, 15, 738, 31, 652, 735, 22], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 17, 18], ["+", 0, 652, 3, 4, 0, 754, 15, 738, 12, 531]]
| 4
| 72
|
while str = STDIN.gets
if str == -1 then break end
a = str.split(' ');
eps = 1e-12;
for i in 0...8 do
a[i] = a[i].to_i
end
if ((a[0]-a[2])*(a[4]-a[6])+(a[1]-a[3])*(a[5]-a[7])).abs <= eps then
puts "YES\n"
else
puts "NO\n"
end
end
|
while str = STDIN.gets
if str == -1 then break end
a = str.split(' ');
eps = 1e-12;
for i in 0...8 do
a[i] = a[i].to_f
end
if ((a[0]-a[2])*(a[4]-a[6])+(a[1]-a[3])*(a[5]-a[7])).abs <= eps then
puts "YES\n"
else
puts "NO\n"
end
end
|
[["-", 0, 88, 8, 170, 0, 662, 12, 652, 735, 22], ["+", 0, 88, 8, 170, 0, 662, 12, 652, 735, 22]]
| 4
| 116
|
while True:
try:
xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
except:
break
if (ya - yb) * (yc - yd) + (xa - xb) * (xc - xd) < 1.e-10:
print('YES')
else:
print('NO')
|
while True:
try:
xa, ya, xb, yb, xc, yc, xd, yd = map(float, input().split())
except:
break
if abs((ya - yb) * (yc - yd) + (xa - xb) * (xc - xd)) < 1.e-10:
print('YES')
else:
print('NO')
|
[["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]]
| 5
| 77
|
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1 else 0
while True:
try:
xa,ya,xb,yb,xc,yc,xd,yd=list(map(float,input().split()))
print('YES' if choco(xa,ya,xb,yb,xc,yc,xd,yd) else 'NO')
except:
break
|
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
while True:
try:
xa,ya,xb,yb,xc,yc,xd,yd=list(map(float,input().split()))
print('YES' if choco(xa,ya,xb,yb,xc,yc,xd,yd) else 'NO')
except:
break
|
[["-", 8, 196, 0, 37, 0, 41, 0, 666, 0, 612], ["+", 8, 196, 0, 37, 0, 41, 0, 666, 0, 531]]
| 5
| 121
|
while True:
try:
x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = map(float, input().split())
ab_x, ab_y = x_b - x_a, y_b - y_a
cd_x, cd_y = x_d - x_c, y_d - y_c
dp = ab_x*cd_x + ab_y*cd_y
if dp > 1e-10:
print("NO")
else:
print("YES")
except:
break
|
while True:
try:
x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = map(float, input().split())
ab_x, ab_y = x_b - x_a, y_b - y_a
cd_x, cd_y = x_d - x_c, y_d - y_c
dp = ab_x*cd_x + ab_y*cd_y
if abs(dp) > 1e-10:
print("NO")
else:
print("YES")
except:
break
|
[["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]]
| 5
| 86
|
while True:
try:
xa,ya,xb,yb,xc,yc,xd,yd=map(float,input().split())
except EOFError:
break
if (ya-yb)*(yc-yd)+(xa-xb)*(xc-xd)<=1e-10:
print("YES")
else:
print("NO")
|
while True:
try:
xa,ya,xb,yb,xc,yc,xd,yd=map(float,input().split())
except EOFError:
break
if abs((ya-yb)*(yc-yd)+(xa-xb)*(xc-xd))<=1e-10:
print("YES")
else:
print("NO")
|
[["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]]
| 5
| 78
|
#include <stdio.h>
int main(void) {
int rank[100][3] = {0}, num, point, i, j, temp, n = 0;
while (1) {
scanf("%d,%d", &num, &point);
if (num == 0 && point == 0)
break;
rank[n][0] = num;
rank[n][1] = point;
}
for (i = 0; i < n; i++) {
for (j = 0; j < n - i - 1; j++) {
if (rank[j][1] < rank[j + 1][1]) {
temp = rank[j][1];
rank[j][1] = rank[j + 1][1];
rank[j + 1][1] = temp;
temp = rank[j][0];
rank[j][0] = rank[j + 1][0];
rank[j + 1][0] = temp;
}
}
}
for (i = 0; i < n; i++) {
if (i == 0) {
rank[i][2] = 1;
} else if (rank[i][1] == rank[i - 1][1]) {
rank[i][2] = rank[i - 1][2];
} else {
rank[i][2] = rank[i - 1][2] + 1;
}
}
while (scanf("%d", &num) != EOF) {
for (i = 0;; i++) {
if (rank[i][0] == num) {
printf("%d\n", rank[i][2]);
break;
}
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int rank[100][3] = {0}, num, point, i, j, temp, n = 0;
while (1) {
scanf("%d,%d", &num, &point);
if (num == 0 && point == 0)
break;
rank[n][0] = num;
rank[n][1] = point;
n++;
}
for (i = 0; i < n; i++) {
for (j = 0; j < n - i - 1; j++) {
if (rank[j][1] < rank[j + 1][1]) {
temp = rank[j][1];
rank[j][1] = rank[j + 1][1];
rank[j + 1][1] = temp;
temp = rank[j][0];
rank[j][0] = rank[j + 1][0];
rank[j + 1][0] = temp;
}
}
}
for (i = 0; i < n; i++) {
if (i == 0) {
rank[i][2] = 1;
} else if (rank[i][1] == rank[i - 1][1]) {
rank[i][2] = rank[i - 1][2];
} else {
rank[i][2] = rank[i - 1][2] + 1;
}
}
while (scanf("%d", &num) != EOF) {
for (i = 0;; i++) {
if (rank[i][0] == num) {
printf("%d\n", rank[i][2]);
break;
}
}
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 0
| 383
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
map<int, int> M;
vector<pair<int, int>> V;
int a, b;
while (scanf("%d,%d", &a, &b), a && b) {
V.push_back(make_pair(b, a));
}
sort(V.begin(), V.end());
reverse(V.begin(), V.end());
int buf = 100, cnt = 0;
for (int i = 0; i < V.size(); i++) {
if (buf > V[i].first) {
buf = V[i].first;
cnt++;
}
M[buf] = cnt;
}
int n;
while (cin >> n) {
int p;
for (int j = 0; j < V.size(); j++) {
if (V[j].second == n) {
p = j;
break;
}
}
cout << M[V[p].first] << endl;
}
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
map<int, int> M;
vector<pair<int, int>> V;
int a, b;
while (scanf("%d,%d", &a, &b), a || b) {
V.push_back(make_pair(b, a));
}
sort(V.begin(), V.end());
reverse(V.begin(), V.end());
int buf = 100, cnt = 0;
for (int i = 0; i < V.size(); i++) {
if (buf > V[i].first) {
buf = V[i].first;
cnt++;
}
M[buf] = cnt;
}
int n;
while (cin >> n) {
int p;
for (int j = 0; j < V.size(); j++) {
if (V[j].second == n) {
p = j;
break;
}
}
cout << M[V[p].first] << endl;
}
}
|
[["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]]
| 1
| 235
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(), (r).end()
#define gsort(st, en) sort((st), (en), greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout << #x << ": " << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repc(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define repi(it, array) \
for (auto it = array.begin(), end = array.end(); it != end; ++it)
#define repa(n, array) for (auto n : (array))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<string, int> dict;
constexpr int imax = ((1 << 30) - 1) * 2 + 1;
constexpr int inf = 100000000;
double eps = 1e-10;
template <typename T> void out(vector<T> v) {
for (size_t i = 0; i < v.size(); i++) {
debug(v[i]);
}
}
template <typename T> string ntos(T i) {
ostringstream s;
s << i;
return s.str();
}
template <typename T> T ston(string str, T n) {
istringstream sin(str);
T num;
sin >> num;
return num;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int num, cor, ans, tmp = -1;
char c;
multimap<int, int> mi;
while (1) {
cin >> num >> c >> cor;
if (num + cor == 0) {
break;
}
mi.insert(make_pair(cor, num));
}
while (cin >> num) {
ans = 0;
for (auto it = mi.rbegin(); it != mi.rend(); ++it) {
if (tmp != it->fi) {
++ans;
tmp = it->fi;
}
if (it->se == num) {
break;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(), (r).end()
#define gsort(st, en) sort((st), (en), greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout << #x << ": " << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repc(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define repi(it, array) \
for (auto it = array.begin(), end = array.end(); it != end; ++it)
#define repa(n, array) for (auto n : (array))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<string, int> dict;
constexpr int imax = ((1 << 30) - 1) * 2 + 1;
constexpr int inf = 100000000;
double eps = 1e-10;
template <typename T> void out(vector<T> v) {
for (size_t i = 0; i < v.size(); i++) {
debug(v[i]);
}
}
template <typename T> string ntos(T i) {
ostringstream s;
s << i;
return s.str();
}
template <typename T> T ston(string str, T n) {
istringstream sin(str);
T num;
sin >> num;
return num;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int num, cor, ans, tmp = -1;
char c;
multimap<int, int> mi;
while (1) {
cin >> num >> c >> cor;
if (num + cor == 0) {
break;
}
mi.insert(make_pair(cor, num));
}
while (cin >> num) {
ans = 0;
tmp = -1;
for (auto it = mi.rbegin(); it != mi.rend(); ++it) {
if (tmp != it->fi) {
++ans;
tmp = it->fi;
}
if (it->se == num) {
break;
}
// cout << it->fi << " " << it->se << endl;
}
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
| 424
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.