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 } 
  • 相关阅读:
    Java——enum与int的转换——转载
    Java——JScrollPane设置透明——转载
    Java——JFrame与JButton添加背景
    Java——模态对话框
    u-boot_2010.6 nandflash驱动彻底分析
    linux 常用命令整理----权限管理
    linux 常用命令整理----链接文件
    linux 常用命令整理----文件操作
    linux 常用命令整理----目录操作
    linux 进程运行状态
  • 原文地址:https://www.cnblogs.com/Annetree/p/6292030.html
Copyright © 2011-2022 走看看