码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-02-14 12:26:28      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:turn   通过   cout   div   平移   post   end   sync   mes   

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


在这里输入题意

【题解】


最后的直角三角形可以通过平移,将直角顶点移动到坐标原点。
然后我们只要枚举另外两个点其中一个点的坐标就好了。
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;
}

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

标签:turn   通过   cout   div   平移   post   end   sync   mes   

原文地址:https://www.cnblogs.com/AWCXV/p/8448065.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!