码迷,mamicode.com
首页 > 移动开发 > 详细

HackerRank - The Trigonometric Ratios (Cold Golf)

时间:2015-04-16 11:48:48      阅读:366      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!