Submission #4061045
Source Code Expand
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
double calc_radius(double l, double theta1, double theta2) {
return l / (1 / tan(theta1 / 2) + 1 / tan(theta2 / 2) + 2);
}
double calc_distance(double x1, double y1, double x2, double y2) {
const double dx = x2 - x1, dy = y2 - y1;
return sqrt(dx * dx + dy * dy);
}
double calc_angle(double dx1, double dy1, double dx2, double dy2) {
const double norm1 = sqrt(dx1 * dx1 + dy1 * dy1);
const double norm2 = sqrt(dx2 * dx2 + dy2 * dy2);
const double inner = dx1 * dx2 + dy1 * dy2;
return acos(inner / (norm1 * norm2));
}
int main(int argc, char *argv[]) {
// read inputs
double xs[3], ys[3];
for (int i = 0; i < 3; i++) {
scanf("%lf %lf", &xs[i], &ys[i]);
}
double ls[3], ts[3];
for (int i = 0; i < 3; i++) {
ls[i] = calc_distance(xs[(i + 1) % 3], ys[(i + 1) % 3], xs[(i + 2) % 3],
ys[(i + 2) % 3]);
ts[i] = calc_angle(xs[(i + 1) % 3] - xs[i], ys[(i + 1) % 3] - ys[i],
xs[(i + 2) % 3] - xs[i], ys[(i + 2) % 3] - ys[i]);
// printf("i = %d, l = %lf, t = %lf\n", i, ls[i], ts[i]);
}
double rs[3], ans = 0;
for (int i = 0; i < 3; i++) {
rs[i] = calc_radius(ls[i], ts[(i + 1) % 3], ts[(i + 2) % 3]);
ans = max(ans, rs[i]);
}
printf("%.15lf\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Inscribed Bicycle |
User |
khir |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1419 Byte |
Status |
AC |
Exec Time |
2 ms |
Memory |
384 KB |
Compile Error
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:28:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lf %lf", &xs[i], &ys[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt |
All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, example0.txt, example1.txt |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
AC |
2 ms |
384 KB |
001.txt |
AC |
1 ms |
128 KB |
002.txt |
AC |
1 ms |
128 KB |
003.txt |
AC |
1 ms |
128 KB |
004.txt |
AC |
1 ms |
128 KB |
005.txt |
AC |
1 ms |
128 KB |
006.txt |
AC |
1 ms |
128 KB |
007.txt |
AC |
1 ms |
128 KB |
008.txt |
AC |
1 ms |
128 KB |
009.txt |
AC |
1 ms |
128 KB |
010.txt |
AC |
2 ms |
256 KB |
011.txt |
AC |
1 ms |
128 KB |
012.txt |
AC |
1 ms |
128 KB |
013.txt |
AC |
1 ms |
128 KB |
014.txt |
AC |
1 ms |
128 KB |
015.txt |
AC |
1 ms |
128 KB |
example0.txt |
AC |
1 ms |
128 KB |
example1.txt |
AC |
1 ms |
128 KB |