首页 > 移动平台 > 详细

HackerRank - The Trigonometric Ratios (Cold Golf)

时间:2015-04-16 11:47:16      阅读:589      评论:0      收藏:0      [点我收藏+]

I tried Python:

def f(x,i,n,a,b,r,s,w):
    if(i>n):return r
    return f(x,i+1,n,a*x*x,b*2*i*(2*i+s),r+a*w/b,s,-w)
n=int(input())
for _ in range(n):
    v=float(input())    
    print(("%.3f"%f(v,1,5,v,1,0,1,1)).rstrip(0))    
    print(("%.3f"%f(v,1,5,1,1,0,-1,1)).rstrip(0))

Looks like 1st on leatherboard is in Ruby.. ok, will try it next time.

HackerRank - The Trigonometric Ratios (Cold Golf)

原文:http://www.cnblogs.com/tonix/p/4431264.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!