显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
const int ans[]={0,2,4,6,10,16,24,36,56,80,118,174,254,378,554,802,1168,1716,2502,3650,5324,7754,11320,16502,24054,35058,51144,74540,108664,158372,230800,336480,490458,714856,1041910,1518840,2213868,3226896,4703372,6855388,9992596};
int n/*,total,rec[50]*/;
/*
void dfs(int deep,int num)
{
int i,j,k,a[4];
rec[deep]=num;
for (i=1;i*3<=deep;i++)
{
for (j=1;j<=3;j++)
{
a[j]=0;
for (k=deep-i*(j-1);k>deep-i*j;k--)
a[j]=(a[j]<<1)+rec[k];
}
if (a[1]==a[2]&&a[2]==a[3])
return;
}
if (deep==n)
{
total++;
return;
}
dfs(deep+1,0);
dfs(deep+1,1);
}
*/
int main(void)
{
freopen("str01.in","r",stdin);
freopen("str01.out","w",stdout);
cin>>n;
/* cout<<"{";
for (n=1;n<=40;n++)
{
total=0;
dfs(1,0);
dfs(1,1);
if (n!=40)
cout<<total<<",";
else
cout<<total<<"};";
}*/
cout<<ans[n]<<endl;
return(0);
}