The radius of earth is 6440 Kilometer. There are many Satellites and Asteroids moving around the earth. If two Satellites create an angle with the center of earth, can you find out the distance between them? By distance we mean both the arc and chord distances. Both satellites are on the same orbit (However, please consider that they are revolving on a circular path rather than an elliptical path).

 

Input

The input file will contain one or more test cases. Each test case consists of one line containing two-integer s and a, and a string ‘min’ or ‘deg’. Here s is the distance of the satellite from the surface of the earth and a is the angle that the satellites make with the center of earth. It may be in minutes (′ ) or in degrees (◦ ). Remember that the same line will never contain minute and degree at a time.

 

Output

For each test case, print one line containing the required distances i.e. both arc distance and chord distance respectively between two satellites in Kilometer. The distance will be a floating-point value with six digits after decimal point.

 

Sample Input

500 30 deg

700 60 min

200 45 deg

 

Sample Output

3633.775503 3592.408346

124.616509 124.614927

5215.043805 5082.035982

 

python:

r=6440
import math
while True:
    try:
        s,a,str=input().split()
        s=int(s)
        a=int(a)
        if str=='min': a/=60
        if a>180: a=360-a
        #弦長 chord = 2* R * cos((90 – a / 2) / 180 * PI)  
        # 弧長 arc = 2 * PI * R * a / 360
        chord=(r+s)* math.cos((90-a/2)/180*math.pi)*2
        arc=2*math.pi*(r+s)*a/360
       # print(round(arc,6),round(chord,6))
        print('%.6f'%arc,'%.6f'%chord)
    except:
        break

 

 

 

arrow
arrow
    文章標籤
    python UVA
    全站熱搜
    創作者介紹
    創作者 趴趴熊日常 的頭像
    趴趴熊日常

    資工趴趴熊的小天地

    趴趴熊日常 發表在 痞客邦 留言(1) 人氣()