【Codeforces Round #239 (Div. 1) A】Triangle

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

最后的直角三角形可以通过平移,将直角顶点移动到坐标原点。 然后我们只要枚举另外两个点其中一个点的坐标就好了。 x坐标的范围是[1..a) 因为再长的话,这条边肯定就超过边长a了。 然后用一些相似三角形的规律就能知道另外一个点的坐标了。 看看这两个点的y坐标是不是一样就好。

【代码】

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

int a,b;

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
    cin >> a >> b;
    for (int i = 1;i  < a;i++){
        int x = i;
        int y = sqrt(a*a-x*x);
        if (y*y+x*x==a*a && b*y%a==0 && b*x%a==0 && b*x/a!=y){
            cout<<"YES"<<endl;
            cout<<"0 0"<<endl;
            cout<<x<<' '<<y<<endl;
            cout<<-b*y/a<<' '<<b*x/a<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
	return 0;
}
posted @ 2018-02-14 11:19  AWCXV  阅读(98)  评论(0编辑  收藏  举报