Create 3566.cpp

This commit is contained in:
Kirigaya Kazuto 2016-10-12 21:36:52 +08:00 committed by GitHub
parent 6efd43b096
commit e4d9a17a87

44
SDUTOJ/3566.cpp Normal file
View File

@ -0,0 +1,44 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int t;
/**
n 0. (++ ++ ==== )
2 0.
1
1 1
1 4
1 13
1 40
1 121
F[ N ] = F [ N -1 ] * 3 +1;
a(n)=(3^(n-1)-1)/2
*/
inline int getTbyte(LL inc)
{
int c=0;
while(inc>0)
{
if(inc&1) ++c;
inc>>=1;
}
return c;
}
int main()
{
scanf("%d",&t);
while(t--)
{
LL inc;
scanf("%lld",&inc);
int n=getTbyte(inc);
if(inc&1 || n == 1)
{
printf("0\n");continue;
}
printf("%lld\n",((LL)pow(3,n-1)-1)/2);
}
return 0;
}