zoukankan      html  css  js  c++  java
  • HDU 1590 Searching(求复数向量和的极限)

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 430    Accepted Submission(s): 77

    Problem Description
    "You know what?" Angel said, "There is a love-letter from me embeded on the lawn. And if you can find it, it's for you~"
    "How can I find it on such a big lawn?"
    "I will show you a hint: start from that tree which is in center of this lawn, and run directly to (X,Y) point. Please memorize the distance you'v passed. Then turn left with a angle A degree, and go ahead for k times of the length you'v passed in the first step. k is a real number from 0 to 1. When you arrive, repeat to turn left, and run for k times as far as the length of the last step. After many many times, you will reach a place, where I embed my letter..."
    Of cause, Gardon wouldn't follow her hint simply. He just run there directly. Can you do it?
     


    Input
    Input have serveral test cases. Each cases have for real number: X,Y,A,k
     


    Output
    For each case, print the place where the treasure is embed.
     


    Sample Input
    1 0 90 0.5
    1 0 90 0
    1 0 0 0.5
     


    Sample Output
    (0.800,0.400)
    (1.000,0.000)
    (2.000,0.000)
     
    //by zyy
     
    题目主要是向量的运算,用复数类complex比较方便,头文件为#include
    向量(x+yi)向左转a角度,大小为原来的k倍,得到向量(x’+y’i)转换公式:
    x’=x*cos(a)-y*sin(a);
    y’=y*cos(a)+x*sin(a);
    =>(x’+y’i)=k*(cos(a)+sin(a)i)*(x+yi);
    可以看出成等比数列;
    题目就是求它的和的极限。
    既:(X,Yi)=(x+yi)/((1,0)-k*(cos(a)+sin(a)i));
     
     1 #include<cstring>
     2 #include<complex>
     3 #include<cmath>
     4 #define pi acos(-1.0)
     5 using namespace std;
     6 typedef complex<double>Comp;
     7 double x,y,A,k;
     8 int main()
     9 {
    10     int i,j;
    11     while(scanf("%lf%lf%lf%lf",&x,&y,&A,&k)!=EOF)
    12     {
    13         A=A*pi/180.0;
    14         Comp a(x,y);
    15         Comp b(1-k*cos(A),-k*sin(A));
    16         Comp c=a/b;
    17        
    18         printf("(%.3lf,%.3lf)
    ",c.real(),c.imag());
    19     }
    20     return 0;
    21 } 
  • 相关阅读:
    逻辑分支
    iOS开发——NSArray中的字符串排序
    iOS开发——实时监控网速(仅作参考,发现一点问题)
    iOS10适配——相机,通讯录,麦克风等权限设置
    iOS10适配——Push Notifications
    iOS开发——获取当前屏幕显示的viewcontroller
    iOS开发——应用图标上显示消息数量
    iOS开发——获取手机当前WiFi名和MAC地址
    我是一个线程(写的太好了,忍不住转过来)
    iOS开发——WAVE音频文件解析
  • 原文地址:https://www.cnblogs.com/Annetree/p/6292030.html
Copyright © 2011-2022 走看看