sdjzuoj 2558:Rescue The Princess

<h3>题目描述</h3><p></p><p><span style="color: rgb(229, 51, 51); line-height: 27px; font-family: 'Microsoft Yahei'; font-size: 18px; background-color: rgb(245, 245, 245);">本题为2013年山东省省赛PROBLEM A</span> </p><p><span style="color: rgb(229, 51, 51); line-height: 27px; font-family: 'Microsoft Yahei'; font-size: 18px; background-color: rgb(245, 245, 245);"><span style="font-size: 12px;"><span style="color: rgb(0, 0, 0);"></span></span></span> </p><p class="MsoNormal"><span>Several days ago, a beast caught a beautiful princess and the princess was put in prison. To rescue the princess, a prince who wanted to marry  the princess set out immediately. Yet, the beast set a maze. Only if the prince find out the maze’s exit can he save the princess.</span> </p><p class="MsoNormal"><span>       Now, here comes the problem. The maze is a dimensional plane. The beast is smart, and he hidden the princess snugly. He marked two coordinates of an <a target=_blank href="app:ds:equilateral">equilateral</a> <a target=_blank href="app:ds:triangle">triangle</a> in the maze. The two marked coordinates are A(x<sub><span style="font-size:12px;">1</span></sub>,y<sub><span style="font-size:12px;">1</span></sub>) and B(x<sub><span style="font-size:12px;">2</span></sub>,y<sub><span style="font-size:12px;">2</span></sub>). The third coordinate C(x<sub><span style="font-size:12px;">3</span></sub>,y<sub><span style="font-size:12px;">3</span></sub>) is the maze’s exit. If the prince can find out the exit, he can save the princess. After the prince comes into the maze, he finds out the A(x<sub><span style="font-size:12px;">1</span></sub>,y<sub><span style="font-size:12px;">1</span></sub>) and B(x<sub><span style="font-size:12px;">2</span></sub>,y<sub><span style="font-size:12px;">2</span></sub>), but he doesn’t know where the C(x<sub><span style="font-size:12px;">3</span></sub>,y<sub><span style="font-size:12px;">3</span></sub>) is. The prince need your help. Can you <a target=_blank href="app:ds:calculate">calculate</a> the C(x<sub><span style="font-size:12px;">3</span></sub>,y<sub><span style="font-size:12px;">3</span></sub>) and tell him?</span> </p>
<p>
</p><p><span style="color: rgb(229, 51, 51); line-height: 27px; font-family: 'Microsoft Yahei'; font-size: 18px; background-color: rgb(245, 245, 245);">
</span> </p><p></p><h3>输入格式</h3><p></p><p class="MsoNormal"><span>The first line is an integer T(1 <= T <= 100) which is the number of test cases. T test cases follow. Each test case contains two coordinates A(x<sub><span style="font-size:12px;">1</span></sub>,y<sub><span style="font-size:12px;">1</span></sub>) and B(x<sub><span style="font-size:12px;">2</span></sub>,y<sub><span style="font-size:12px;">2</span></sub>), described by four floating-point numbers x<sub><span style="font-size:12px;">1</span></sub>, y<sub><span style="font-size:12px;">1</span></sub>, x<sub><span style="font-size:12px;">2</span></sub>, y<sub><span style="font-size:12px;">2</span></sub> ( |x<sub><span style="font-size:12px;">1</span></sub>|, |y<sub><span style="font-size:12px;">1</span></sub>|, |x<sub><span style="font-size:12px;">2</span></sub>|, |y<sub><span style="font-size:12px;">2</span></sub>|<sub><span style="font-size:12px;"> </span></sub><= 1000.0).</span> </p><p class="MsoNormal" style="text-indent: 21pt;"><span>Please notice that A(x<sub><span style="font-size:12px;">1</span></sub>,y<sub><span style="font-size:12px;">1</span></sub>) and B(x<sub><span style="font-size:12px;">2</span></sub>,y<sub><span style="font-size:12px;">2</span></sub>) and C(x<sub><span style="font-size:12px;">3</span></sub>,y<sub><span style="font-size:12px;">3</span></sub>) are in an anticlockwise direction from the <a target=_blank href="app:ds:equilateral">equilateral</a> <a target=_blank href="app:ds:triangle">triangle</a>. And coordinates A(x<sub><span style="font-size:12px;">1</span></sub>,y<sub><span style="font-size:12px;">1</span></sub>) and B(x<sub><span style="font-size:12px;">2</span></sub>,y<sub><span style="font-size:12px;">2</span></sub>) are given by anticlockwise.<strong></strong></span> </p><p></p><h3>输出</h3><p></p><p class="MsoNormal"><span>For each test case, you should output the coordinate of C(x<sub><span style="font-size:12px;">3</span></sub>,y<sub><span style="font-size:12px;">3</span></sub>), the result should be rounded to 2 decimal places in a line.</span> </p><p></p><h3>样例输入</h3><p><span style="font-family: 'Lucida Console';">4
 -100.00 0.00 0.00 0.00
 0.00 0.00 0.00 100.00
 0.00 0.00 100.00 100.00
 1.00 0.00 1.866 0.50
</span></p><h3>样例输出</h3><p><span style="font-family: 'Lucida Console';">(-50.00,86.60)
 (-86.60,50.00)
 (-36.60,136.60)
 (1.00,1.00)
</span></p>
今天学长刚讲了这道题,要我们做做看看,主要是套模板,不要忘了求出来的是向量,要转变成坐标哦(*^__^*);

#include<stdio.h>
#include<math.h>
#define cosA 0.5
#define sinA 0.8660254

int main()
{
    int n;
    double x, y, x0, y0;
    double x1, y1, x2, y2;
    scanf("%d",&n);
    while(n --)
    {
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
        x = x2 - x1;
        y = y2 - y1;
        x0 = x * cosA - y * sinA;//得到的向量
        y0 = x * sinA + y * cosA;//得到的向量
        printf("(%.2f,%.2f)\n",x0 + x1,y0 + y1);//求坐标还要加上原坐标。
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值