烙印
烙印
https://ac.nowcoder.com/acm/contest/7745/B
思路:
先复习一下三角形全等条件,SSS,SAS,AAS,ASA
分析题目,可以分为一下几个情况
1.3条边
2.3个角
3.1个边2个角
4.一个角2个边
1只有1种,2有无穷种,3有AAS和ASA都只有一种,4有SAS和SSA两种,特判一下SSA的情况就行。
然后再考虑一下构不成三角形的情况。
#include<bits/stdc++.h> #define eps 1e-8 using namespace std; const double pi = acos(-1.0); int g[5], s[5]; bool SAS() { int sum = 0; for(int i = 0; i < 3; i++) { if(s[i] != -1 && g[i] != -1) return 0; } return 1; } void solve() { double a, b, o; for(int i = 0; i < 3; i++) { if(s[i]!= -1 && g[i] != -1) { b = 1.0*s[i]; o = 1.0*g[i]; } else if(s[i] != -1 && g[i] == -1) { a = 1.0*s[i]; } } if(o > 90) { if(b > a) { cout << 1 << endl; } else { cout << 0 << endl; } return ; } if(b+eps < a*sin(o/180*pi)) { cout << 0 << endl; } else if(fabs(b - a*sin(o/180*pi)) < eps) { cout << 1 << endl; } else if(b < a && b > eps + a*sin(o/180*pi)){ cout << 2 << endl; } else { cout << 1 << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--) { int cnts = 0, cntg = 0; for(int i = 0; i < 3; i++) { cin >> s[i]; if(s[i] != -1) { cnts++; } } for(int i = 0; i < 3; i++) { cin >> g[i]; if(g[i] != -1) { cntg++; } } int op; if(cnts == 3) {///SSS op = 1; } else if(cntg == 3) {///AAA op = 2; } else if(cnts == 1 && cntg == 2) {///ASA AAS op = 3; } else if(cnts == 2 && cntg == 1) {///SSA SAS op = 4; } if(op == 1){ if(s[0] + s[1] > s[2] && s[1] + s[2] > s[0] && s[0] + s[2] > s[1]) { cout << 1 << endl; } else { cout << 0 << endl; } } else if(op == 2) { if(g[0] + g[1] + g[2] == 180) { cout << "syksykCCC" << endl; } else { cout << 0 << endl; } } else if(op == 3) { int sum = 0; for(int i = 0; i < 3; i++) { if(g[i] != -1) { sum += g[i]; } } if(sum < 180) { cout << 1 << endl; } else { cout << 0 << endl; } } else if(op == 4) { if(SAS()) { cout << 1 << endl; } else { solve(); } } } return 0; }