传送门:www.lydsy.com/JudgeOnline/problem.php?id=2656
Python水题
d={} def f(x): if x==0: return 0 if x==1: return 1 if d.has_key(x): return d[x] if x%2==0: ans=f(x/2) d[x]=ans else: ans=f(x/2) ans+=f(x/2+1) d[x]=ans return ans T=int(raw_input()) for i in range(0,T): x=int(raw_input()) print f(x)