Submission #1611199


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

using D=double;
using Point=complex<double>;
struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};


D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point crossPoint(const Segment &s1,const Segment &s2){
    Point  base=s2.p2-s2.p1;
    D d1=abs(cross(base,s1.p1-s2.p1));
    D d2=abs(cross(base,s1.p2-s2.p1));

    D t=d1/(d1+d2);
    return s1.p1+(s1.p2-s1.p1)*t;
}



signed main(){
    int X,Y,Z;
    cin>>X>>Y>>Z;

    D d=sqrt(X*X+Y*Y);
    D sn=Y/d;
    D co=X/d;

    Segment s=Segment(Point(0,0),Point(0,X));
    Segment t=Segment(Point(Y,0),Point(-sn*Z,X-co*Z));

    Point p=crossPoint(s,t);

    printf("%.20f\n",X-imag(p));
    return 0;
}

Submission Info

Submission Time
Task D - くさかべ
User ei13333333333
Language C++14 (GCC 5.4.1)
Score 1
Code Size 1234 Byte
Status AC
Exec Time 1 ms
Memory 256 KiB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1 / 1
Status
AC × 2
AC × 14
Set Name Test Cases
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
Case Name Status Exec Time Memory
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