æ¨æ¥ã®æ¼¸åå¼ãï¼£ã§ã³ã¼ãã£ã³ã°ããã¨
ã¦æãã§å帰å¼åºãã«ãªããçµæçã«å ¨ã¦ã®å ´åã調ã¹ãã®ã§è¨ç®æé㯠exp(N) ã®ãªã¼ãã¼ã§å®éã¯ä¸å¯è½ãã§ãéåã³ã³ãã¥ã¼ã¿ã§ãã¾ãããã° O(N)æéã§ã§ããªãããªãçµæã¯ï¼ãï¼ããªãã§ããã確ççã«ã§ãæ£ãã観測ã§ããã°ããããã§ããã
extern int f_2n(move a[N], b[N]);
int f(int n, move a[N], b[N]){
int dummy, result, i;
if(n==2N) return f_2n(a,b);
if (n&1==1){
result=1;
for(i=0;iï¼MOVE_MAX;i++) { b[n/2]=i;result &= f(n+1,a,b);}
}else{
result=0;
for(i=0;iï¼MOVE_MAX;i++) { a[n/2]=i;result |= f(n+1,a,b);}
}
return result;
}
main(){
move a[N],b[N];
if (f(0,a,b)==1) printf("å æå¿ å\n"); else printf("å¾æå¿ å\n");
}
å®å ¨æ å ±äºäººã²ã¼ã ã® Itakura ã®éåã¢ã«ã´ãªãºã ï¼ï¼ï¼ï¼
å§ã㫠Σ f(A1,B1,..An,Bn)|A1B1A2B2..AnBnï¼ ã¨ããç¶æ ãä½ã£ã¦ã¦ãã¿ãªå¤æããã¦ãã£ã¦ããããã¼ãã®åæç¶æ ãä½ãã®ãä¸å¯è½ããO(N)åæ°ã®å¤æã§åæç¶æ ãä½ãããããªåç´ãªfã¤ã¾ãåæã®ã«ã¼ã«ãªãå ã èªæã ãããããã£ã±ãã¡ãã
ãã¤ãã³ã®è¨¼æã¯ããããé§ã®é ç½®ã«å¯¾ãã¦æãæãå®ç¾©ãããã®ããæ¦ç¥ãã¨å®ç¾©ããã¨ãå©å¾è¡åãèããã¨ããããã¯ã¹å®çã使ãã¦ãã¨ããæãããããã ãã¶æããéããªã