无心人 发表于 2013-6-17 22:13:53

2=>1,3,4,5,6,7,9
3=>2,4,5,6,8
4=>1,2,3,5,7,8,9
5=>1,2,3,4,6,7,8,9

无心人 发表于 2013-6-17 22:15:29

6=>1,2,3,5,7,8,9
7=>2,4,5,6,8
8=>1,3,4,5,6,7,9
9=>2,4,5,6,8

wayne 发表于 2013-6-18 15:07:10

不错,这种方法好是好,只是有一种情况没考虑吧。
比如,前面如果已经经过5的话,后面4可以直接跳到6的

参考6#可行方案的2516图
路径{8,5,7,4,6}

无心人 发表于 2013-6-18 15:30:48

待我写个程序来

无心人 发表于 2013-6-18 16:37:48


#include <stdio.h>

int mask = {1,0,0,0,0,0,0,0,0,0};
int next =
{0,0,0,0,0,0,0,0,0,0,
5,2,4,5,6,8,0,0,0,0,
7,1,3,4,5,6,7,9,0,0,
5,2,4,5,6,8,0,0,0,0,
7,1,2,3,5,7,8,9,0,0,
8,1,2,3,4,6,7,8,9,0,
7,1,2,3,5,7,8,9,0,0,
5,2,4,5,6,8,0,0,0,0,
7,1,3,4,5,6,7,9,0,0,
5,2,4,5,6,8,0,0,0,0,
};
int counter = {0,0,0,0,0,0,0,0,0,0};
int graph = {0,0,0,0,0,0,0,0,0,0};
int nextNumber = 0;
int graphPostion = 0;

void first( void )
{
int i;
for (i = 1; i <= 9 ; i ++)
{
    mask = 1;
        graph = i;
        circle( graphPostion + 1 );
    mask = 0;
}
}

void circle( int graphPostion )
{
int i;
int noPostion = 1;
int n = graph;
for (i = 1; i <= next; i ++)
{
    if (mask] == 0)
        {
          noPostion = 0;
          mask] = 1;
          graph = next;
          counter ++;
          circle( graphPostion + 1 );
          mask] = 0;          
        }
}   

if (noPostion)
{
    printf("find: ");
    for (i = 0; i < graphPostion; i ++)
    {
          printf("%1d", graph);
    }
        printf("\n");
}       
}

int main ( void )
{
int i;
first( );
for (i = 4; i <= 9; i ++)
    printf("%d: %d\n", i, counter);
return 0;
}
4: 1400
5: 5328
6: 16032
7: 35328
8: 49536
9: 32256

wayne 发表于 2013-6-18 17:46:22

PointsToBeChecked[{{a_,b_},{c_,d_}}]:=Module[{g=GCD},If,{}]];
n=3;ddd=Flatten,1];
Table[{ii,Product,ddd=Select&/@Complement-1,1],ii],{ii,ddd}],1],Length]]]==0&];Length},{ii,2,n^2}]对算法做了改进,反而跟无心人的答案对上了。
{2, 72, 56},
{3, 504, 304},
{4, 3024, 1400},
{5, 15120, 5328},
{6, 60480, 16032},
{7, 181440, 35328},
{8, 362880, 49536},
{9, 362880, 32256}}

wayne 发表于 2013-6-18 21:41:54

算得4*4的情况:
2,240,172
3,3360,1696
4,43680,15580
5,524160,132264
6,5765760,1029232
7,57657600,7286016
后面就算不动了

无心人 发表于 2013-6-19 14:37:53

:)

证明俺算法没错了哦

mathematica 发表于 2013-6-20 13:29:19

取出所有的排列,然后一个一个地判定!

gogdizzy 发表于 2013-6-24 11:29:36

看了下无心人的程序,能计算#6给出的合法情况吗?
5->2->7->3->4

因为5是已经标记过的,所以可以从7直接到3了。
页: 1 [2] 3
查看完整版本: 关于android手机图案锁屏的计数