【SWTR-02】Sweet Round 02 T1 Triangles

· · 题解

\color{orange}T1.\ Triangles

\color{orange}\text{题面}

\color{orange}\text{官方题解}

小学数学级别

主要考察的是 \mathrm{OIers} 的数学功底

暴力分:100\%

对于第一问,只有可能是以下四种答案:

x/2\quad x\quad 180-x* 2\quad (180-x)/2

由于 0<x<90,所以上面四种答案都是合法的

别忘了排序,去重

对于第二问,只有可能是以下两种答案

\sqrt{n*n-m*m}\quad \sqrt{n*n+m*m}

n=m 时,第一种答案不存在

代码:

#include<bits/stdc++.h>
using namespace std;
#define ld double
ld x,m,n;
void solve1()
{
    vector <ld> ans;
    ans.push_back(x);
    ans.push_back(180-x*2);
    ans.push_back((180-x)/2);
    ans.push_back(x/2);
    sort(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++)
        if(i==0||ans[i]!=ans[i-1])
            cout<<ans[i]<<" ";
    puts("");
}
void solve2()
{
    ld sq1=n*n+m*m,sq2=n*n-m*m;
    if(sq2!=0)printf("%.5lf ",sqrt(sq2));//因为 sq2 一定比 sq1 小,所以我们先输出 sq2
    printf("%.5lf ",sqrt(sq1));
    puts("");
}
int main()
{
    cin>>x>>m>>n;
    solve1();
    solve2();
    return 0;
}