牛客练习赛71 B-烙印 (几何)

牛客练习赛71 B-烙印 (几何)

题面:

思路:

\(cnt\_angle\)代表数据中给出的角的个数,

那么我们不妨对\(cnt\_angle\)\(0,1,2,3\)进行分类讨论处理:

  • 如果给出角度之和大于180,则答案为0.

  • \(cnt\_angle=0\),即数据给定的是三个边的长度,

那么我们只需要判断三个边是否构成三角形即可,若构成则答案为1,否则答案为0.

判断的方法有很多种,比较好写的是判断三个边的和是否大于三个边中最大值的二倍。

  • \(cnt\_angle=1\),即数据给定的是两个边的长度,

我们将给定的角转化为角\(\mathit a\)

如果角\(\mathit a\) 的对边\(\mathit A\) 的没有给出,那么两边夹一角唯一确定一个三角形。

否则对面给出了:

如果\(90\leq a\),即该角度为直角或钝角,根据大边对大角的性质,对边\(\mathit a\) 要大于给出的另外一个边。

\(a<90\)的话,判断对边为半径的圆与没给出的那个临边的交点个数就是答案。

  • \(cnt\_angle=2\),答案为1.(给出角度之和小于180).
  • \(cnt\_angle=3\),角度之和为180的话,答案为无穷,否则为0.

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') { fh = -1; } c = getchar();} while (c >= '0' && c <= '9') { tmp = tmp * 10 + c - 48, c = getchar(); } return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') { fh = -1; } c = getchar();} while (c >= '0' && c <= '9') { tmp = tmp * 10 + c - 48, c = getchar(); } return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
bool check(int a, int b, int c)
{
    return a + b + c > max(a, max(b, c)) * 2;
}
int a, b, c, A, B, C;
int solve(double angle, int c, int a)
{
    int ans;
    double dis = c * sin(angle);
    if (a > dis + 1e-8 ) {
        if (a < c) {
            ans = 2;
        } else {
            ans = 1;
        }
    } else if (fabs(dis - a) < 1e-8) {
        ans = 1;
    } else {
        ans = 0;
    }
    return ans;
}
int main()
{
#if DEBUG_Switch
    freopen("D:\\code\\input.txt", "r", stdin);
#endif
    //freopen("D:\\code\\output.txt","w",stdout);
    int t;
    t = readint();
    while (t--) {
        a = readint(), b = readint(), c = readint(), A = readint(), B = readint(), C = readint();
        int sum = 0;
        int cnt_angle = 0;
        if (A != -1) {
            sum += A;
            cnt_angle++;
        }
        if (B != -1) {
            sum += B;
            cnt_angle++;
        }
        if (C != -1) {
            sum += C;
            cnt_angle++;
        }
        if (sum > 180 || A == 0 || B == 0 || C == 0) {
            printf("0\n");
            continue;
        }
        if (cnt_angle == 3) {
            if (sum == 180) {
                printf("syksykCCC\n");
                continue;
            } else {
                printf("0\n");
                continue;
            }
        } else {
            if (sum == 180) {
                printf("0\n");
                continue;
            } else if (cnt_angle == 0) {
                if (check(a, b, c)) {
                    printf("1\n");
                } else {
                    printf("0\n");
                }
            } else if (cnt_angle == 1) {
                double angle;
                int ans = 0;
                if (C != -1) {
                    swap(A, C);
                    swap(a, c);
                }
                if (B != -1) {
                    swap(B, A);
                    swap(b, a);
                }
                angle = 1.0 * A / 180 * acos(-1);
                if (a == -1) {
                    printf("1\n");
                    continue;
                }
                if (A >= 90) {
                    int temp = max(b, c);
                    if (a > temp) {
                        printf("1\n");
                    } else {
                        printf("0\n");
                    }
                    continue;
                }
                if (b == -1) {
                    ans = solve(angle, c, a);
                }
                if (c == -1) {
                    ans = solve(angle, b, a);
                }
                printf("%d\n", ans);

            } else if (cnt_angle == 2) {
                printf("1\n");
            }
        }
    }
    return 0;
}



posted @ 2020-10-10 16:45  茄子Min  阅读(174)  评论(0编辑  收藏  举报