-
Notifications
You must be signed in to change notification settings - Fork 1
9-froglike6 #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
9-froglike6 #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ λ κ°μ λ°©μμΌλ‘ ν΄κ²°νμ΅λλ€..
μ΅κ·Όμ 곡νμνμ νκ³ μμ΄μ κ·Έλλ§ ν μ μλ λ¬Έμ μλ€μ.
μ¬κΈ°μ μ½λλ₯Ό λ κ°μ ν μ μλ κ³ λ―Όν΄λ΄€λλ° μμ§μ λ§λ ν λ μ€λ₯΄λ κ°μ μ μ΄ λ³΄μ΄μ§ μλ€μ
λ§μ§λ§μ μ λ΅μ μ λ μΈ ννμ¬λ³νμ λλ λ₯Ό μ λ ¬ν΄μ ꡬνλλ°
μ΄ λΆλΆμμλ μ½κ°μ μ°¨μ΄κ° μλ€μ γ
γ
C++μμλ μμμ κ³ μ μ ν΄μ€μΌ ACκ° λ¨λλΌκ΅¬μ
C++
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
double x_A, y_A, x_B, y_B, x_C, y_C;
double length_AB, length_AC, length_BC;
double square[3] = { 0 };
cin >> x_A >> y_A >> x_B >> y_B >> x_C >> y_C;
double cross = (x_B - x_A) * (y_C - y_B) - (y_B - y_A) * (x_C - x_B);
if(cross == 0) {
cout << "-1.0";
return 0;
}
length_AB = sqrt((x_A - x_B) * (x_A - x_B) + (y_A - y_B) * (y_A - y_B));
length_AC = sqrt((x_A - x_C) * (x_A - x_C) + (y_A - y_C) * (y_A - y_C));
length_BC = sqrt((x_B - x_C) * (x_B - x_C) + (y_B - y_C) * (y_B - y_C));
square[0] = (length_AB + length_AC) * 2;
square[1] = (length_AB + length_BC) * 2;
square[2] = (length_AC + length_BC) * 2;
sort(square, square + 3);
cout << fixed;
cout.precision(16);
cout << square[2] - square[0];
return 0;
}
caucsejunseo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μν λ¬Έμλ λ³Ό λλ§λ€ μλ‘λ€μ!
μΈ μ μ΄ μΌμ§μ μ΄ λλ©΄ μλλ€λ λΉμ°ν κ²λ μ λ°λ‘λ°λ‘ μκ°μ΄ μλλμ§ μ€λ κ³ λ―Όνλ€μ
μ²μμ Dμ£ν μꡬνκ³ κ·Έλ₯ AB, AC, BC μ λΆ κΈΈμ΄λ§ ꡬν΄μ ν μ μμμ€ μκ³ νλ€κ° λ§μ΄ νλ Έμ΅λλ€...
C
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
double distance(double x1, double y1, double x2, double y2) {
return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}
int main() {
double x1, y1, x2, y2, x3, y3;
scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
if ((x2 - x1)*(y3 - y1) == (x3 - x1)*(y2 - y1)) {
printf("-1.0\n");
return 0;
}
double d1 = distance(x1, y1, x2, y2) + distance(x3, y3, x2 - x1 + x3, y2 - y1 + y3); // A-B κΈ°μ€
double d2 = distance(x1, y1, x3, y3) + distance(x2, y2, x3 - x1 + x2, y3 - y1 + y2); // A-C κΈ°μ€
double d3 = distance(x2, y2, x3, y3) + distance(x1, y1, x3 - x2 + x1, y3 - y2 + y1); // B-C κΈ°μ€
d1 *= 2;
d2 *= 2;
d3 *= 2;
double max = d1;
if (d2 > max) max = d2;
if (d3 > max) max = d3;
double min = d1;
if (d2 < min) min = d2;
if (d3 < min) min = d3;
printf("%.10lf\n", max - min);
return 0;
}
hadongun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ²μμ λνλμ΄ μ°μ λ°©λ²μΈ μΈ μ μ 거리 μ€ 2κ°μ© κ³¨λΌ λνλ λ°©μμ λ μ¬λ ΈμΌλ ꡬ체ν νλ κ³Όμ μμ μ€μκ° μμ΄μ μλͺ»λ λ°©λ²μΈ μ€ μμλ€μ.. μ΄ν Dμ μ μ’νλ₯Ό ꡬνλ € νμΌλ.. μ€ν¨νμλ€μ₯.. μ§μ 그리μλ©΄μ μμ΄λμ΄λ₯Ό μκ°νλ λ°©μμ μ’μ κ² κ°μμ..!
κ²°κ΅ λνλκ³Ό λΉμ·ν λ°©λ²μΌλ‘ ν΄κ²°νμ΅λλ€.
Ομ¬
import sys
import math
x_a, y_a, x_b, y_b, x_c, y_c = map(int, input().split())
if (y_b- y_a) * (x_c - x_b) == (y_c - y_b) * (x_b - x_a):
print(-1)
sys.exit()
ab_line = math.sqrt((x_a - x_b)*(x_a - x_b) + (y_a - y_b)*(y_a - y_b))
ac_line = math.sqrt((x_a - x_c)*(x_a - x_c) + (y_a - y_c)*(y_a - y_c))
bc_line = math.sqrt((x_c - x_b)*(x_c - x_b) + (y_c - y_b)*(y_c - y_b))
p1 = 2 * (ab_line + ac_line)
p2 = 2 * (ab_line + bc_line)
p3 = 2 * (ac_line + bc_line)
line_list = [p1, p2, p3]
line_list.sort()
print(f"{line_list[2]-line_list[0]:.10f}")
π λ¬Έμ λ§ν¬
ννμ¬λ³ν
βοΈ μμλ μκ°
30λΆ
β¨ μλ μ½λ
μλ μ½λ
μ΄ λ¬Έμ λ μΈ μ μ΄ μ£Όμ΄μ§ λ λ§λ€ μ μλ ννμ¬λ³ν μ€, κ°μ₯ κΈ΄ λλ μ κ°μ₯ μ§§μ λλ μ μ°¨λ₯Ό ꡬνλ λ¬Έμ μ λλ€.


$A$ λ₯Ό μμ μΌλ‘ νλ 벑ν°λ₯Ό λ§λ€μ΄μ λ΄μ μ ν©λλ€.

$sin \theta=0$ μ΄λ―λ‘). μ΄μ μΈ μ μ¬μ΄μ 거리λ₯Ό ꡬν©λλ€.


μμ κ°μ΄ μΈ μ μ΄ μμ΅λλ€. λ¨Όμ μΈ μ μ΄ ν μ§μ μμ μμΌλ©΄ ννμ¬λ³νμΌλ‘ λͺ» λ§λ€κΈ° λλ¬Έμ, μ΄λ₯Ό λ¨Όμ νλ³ν©λλ€.
λ΄μ κ²°κ³Όκ° 0μ΄λ©΄ ν μ§μ μμ μλ€λ κ²μ μ μ μμ΅λλ€(
μ΄ κ±°λ¦¬λ₯Ό μ΄μ©ν΄μ, λ§λ€μ΄μ§ μ μλ ννμ¬λ³ν λλ κ°μ λ°μ ꡬν μ μμ΅λλ€.
μΈ μ μ 거리 μ€ 2κ°μ© κ³¨λΌ λνλ©΄, ννμ¬λ³νμ λλ μ λ°μ΄ λ©λλ€. λ°λΌμ λͺ¨λ κ²½μ°λ₯Ό ꡬνκ³ , μ΅λκ°μμ μ΅μκ°μ λΊ ν, 2λ°°νμ¬ μΆλ ₯νλ©΄ λ¬Έμ κ° ν΄κ²°λ©λλ€.
μ²μμλ ννμ¬λ³νμ λλ¨Έμ§ ν μ μ μ§μ ꡬνκ³ μ νλλ°, κ·Έλ¦Όμ 그리λ€λ³΄λ μ΄λ¬ν λ°©λ²μ΄ μκ°λ¬μ΅λλ€.
π μλ‘κ² μκ²λ λ΄μ©
μ§κ°μΌκ°νμ΄λ 벑ν°μ λ Έλ¦μ ꡬνλ νμ΄μ¬ ν¨μ
math.hypotμ΄λΌλ ν¨μλ₯Ό μκ² λμμ΅λλ€. κΈ°μ‘΄μλ μ§μ μμ ꡬννλλ°, μ΄ ν¨μλ₯Ό μ°λ©΄ μ‘°κΈ λ κ°λ¨ν΄μ§λ€μ γ γ