contest 1.19
A.Little Sub and Pascal's Triangle
求杨辉三角形第n行(n=0,1,...)的奇数个数
规律:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> typedef long long ll; using namespace std; ll f(ll x){ if(x==0) return 1; ll now=1; while(now*2<=x) now*=2; return 2*f(x-now); } int main() { ll t;scanf("%lld",&t); while(t--){ ll k;scanf("%lld",&k); k--; ll ans=f(k); printf("%lld\n",ans); } return 0; }
转载请注明出处:https://www.cnblogs.com/lllxq/