提出 #1611334


ソースコード 拡げる

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

typedef complex<double> Point;
typedef Point Vector;

struct Segment{ Point p1, p2; };
typedef Segment Line;

double cross(Point a, Point b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

Point intersectionL(Point a1, Point a2, Point b1, Point b2){
	Point a = a2 - a1; Point b = b2 - b1;
	return a1 + a* cross(b, b1 - a1) / cross(b, a);
}
Point intersectionL(Line l1, Line l2){
	return intersectionL(l1.p1, l1.p2, l2.p1, l2.p2);
}

double x, y, z;

bool C(double mid){
	Point A = Point{0,x};
	Point C = Point{y,0};
	Point P = Point{0,mid};
	Point Q = Point{y,mid * 2};

	Line l1 = Line{P,Q};
	Line l2 = Line{A,C};

	Point crs = intersectionL(l1, l2);
	double ver = z / abs(A - C) * y;
	double hol = z / abs(A - C) * x;
	//show(crs)
	
	Point Z = Point{hol, x - ver};
	//show(abs(crs - A))

	return abs(crs - A) < abs(Z - A);
}

int main(){
	cin >> x >> y >> z;

	double right = x, left = 0;
	rep(i,200){
		double mid = (right + left ) / 2;
		if(C(mid)) right = mid;
		else left = mid;
	}
	//show(right)
	cout << fixed << setprecision(10) << x - right << endl;
}

提出情報

提出日時
問題 D - くさかべ
ユーザ rippro_tekitou
言語 C++14 (GCC 5.4.1)
得点 1
コード長 1389 Byte
結果 AC
実行時間 1 ms
メモリ 256 KiB

ジャッジ結果

セット名 sample all
得点 / 配点 0 / 0 1 / 1
結果
AC × 2
AC × 14
セット名 テストケース
sample sample-01.txt, sample-02.txt
all sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, sample-01.txt, sample-02.txt
ケース名 結果 実行時間 メモリ
01-01.txt AC 1 ms 256 KiB
01-02.txt AC 1 ms 256 KiB
01-03.txt AC 1 ms 256 KiB
01-04.txt AC 1 ms 256 KiB
01-05.txt AC 1 ms 256 KiB
01-06.txt AC 1 ms 256 KiB
01-07.txt AC 1 ms 256 KiB
01-08.txt AC 1 ms 256 KiB
01-09.txt AC 1 ms 256 KiB
01-10.txt AC 1 ms 256 KiB
sample-01.txt AC 1 ms 256 KiB
sample-02.txt AC 1 ms 256 KiB