解法
どれか二線の交点がなかったら凶。
あったら、3つの交点を求めてヘロンの公式S=√s(s-a)(s-b)(s-c)で面積を求めてはっぴー
ソース
int main(){ L ls[3]; int x1[3], y1[3], x2[3], y2[3]; while( cin >> x1[0] >> y1[0] >> x2[0] >> y2[0], x1[0]|y1[0]|x2[0]|y2[0] ){ for(int i = 1 ; i < 3 ; i++ ){ cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; } for(int i = 0 ; i < 3 ; i++ ){ ls[i] = L( P( x1[i], y1[i]), P( x2[i], y2[i])); } G triangle(3); bool flag = true; for(int i = 0 ; i < 3 ; i++ ){ const int NEXT = ( i + 1 ) % 3; if(!intersect( ls[i], ls[NEXT])){ flag = false; break; }else{ triangle[i] = crosspoint( ls[i], ls[NEXT]); } } double s = (abs(triangle[0]-triangle[1])+abs(triangle[1]-triangle[2])+abs(triangle[2]-triangle[0])) / 2; double area = sqrt(s * ( s - abs(triangle[0] - triangle[1])) * ( s - abs(triangle[1] - triangle[2])) * ( s - abs(triangle[2] - triangle[0]))); if(!flag || area < EPS) cout << "kyo" << endl; else if(area < 100000) cout << "syo-kichi" << endl; else if(area < 1000000) cout << "kichi" << endl; else if(area < 1900000) cout << "chu-kichi" << endl; else cout << "dai-kichi" << endl; } }
0 件のコメント:
コメントを投稿