正解:$dp$
解题报告:
传送门$QwQ$
考虑列一个横坐标为比值为2的等比数列,纵坐标为比值为3的等比数列的表格.发现每个数要选就等价于它的上下左右不能选.
于是就是个状压$dp$板子了$QwQ$
然后因为有些数是无关联的就不会在一个表格中($eg:1,5$.所以要建多个表格,最后乘法原理就好,$over$
#includeusing namespace std; #define il inline #define gc getchar() #define ri register int #define rb register bool #define rc register char #define lowbit(x) (x&(-x)) #define rp(i,x,y) for(ri i=x;i<=y;++i) #define my(i,x,y) for(ri i=x;i>=y;--i) const int N=100000+10,mod=1000000001; int n,as=1,cnt,num[35],f[35][N];//说下昂QwQ,就这里这个[N]不是原本的N的意义,,,只是恰好等于N.QwQ bool vis[N]; vector<int>V[35]; il int read() { rc ch=gc;ri x=0;rb y=1; while(ch!='-' && (ch>'9' || ch<'0'))ch=gc; if(ch=='-')ch=gc,y=0; while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc; return y?x:-x; } il void build(ri x) {cnt=0;while(x<=n){ri tmp=x;num[++cnt]=0;while(tmp<=n)++num[cnt],vis[tmp]=1,tmp<<=1;x=1ll*x*3;}} il bool check(ri x){ri pre=0;while(x){ri tmp=lowbit(x);if(tmp==(pre<<1))return 0;pre=tmp;x-=pre;}return 1;} il void pre(){rp(i,1,cnt){V[i].clear();rp(j,0,(1< 1)if(check(j))V[i].push_back(j);}} il void inc(ri &x,ri y){x+=y;if(x>=mod)x-=mod;} il int cal() { pre();ri ret=0; rp(i,1,cnt){ri sz=V[i].size();rp(j,0,sz-1)f[i][j]=(i==1);} rp(i,2,cnt) { ri sznw=V[i].size(),szpr=V[i-1].size(); rp(j,0,sznw-1){rp(k,0,szpr-1)if(!(V[i][j]&V[i-1][k]))inc(f[i][j],f[i-1][k]);if(i==cnt)inc(ret,f[i][j]);} } if(cnt==1)ret=V[1].size(); return ret; } int main() { //freopen("3226.in","r",stdin);freopen("3226.out","w",stdout); n=read();rp(i,1,n)if(!vis[i]){build(i);as=1ll*as*cal()%mod;}printf("%d\n",as); return 0; }