zoukankan      html  css  js  c++  java
  • HDU 2510

    DFS后打表

     1 #include <iostream>
     2 using namespace std;
     3 int s[] ={0,0,0,4,6,0,0,12,40,0,0,171,410,0,0,1896,5160,0,0,32757,59984,0,0,431095,822229};
     4 int main()
     5 {
     6     int n;
     7     while(~scanf("%d",&n)&n)
     8     {
     9         printf("%d %d
    ",n,s[n]);                          
    10     }
    11 }
     1 #include <iostream>
     2 using namespace std;
     3 int s[25][25];
     4 int a,b;
     5 int n,cnt;
     6 void dfs(int x)
     7 {
     8     if(x==n+1)
     9     {
    10         int i,j;
    11         a=b=0;
    12         for(j=1;j<=n;j++) 
    13         if(s[1][j]) a++;
    14         else b++;
    15         for(int i=2;i<=n;i++)
    16         {
    17             for(j=1;j<=n-i+1;j++)
    18             {
    19                 if(s[i-1][j]==s[i-1][j+1]) {
    20                     s[i][j]=1;
    21                     a++;
    22                 } else {
    23                     s[i][j]=0;
    24                     b++;
    25                 }
    26             }
    27         }
    28         if(a==b) cnt++;
    29         return;
    30     }
    31     s[1][x]=0;
    32     dfs(x+1);
    33     s[1][x]=1;
    34     dfs(x+1);
    35 }
    36 int main()
    37 {
    38     for(n=1;n<=24;n++) 
    39     {
    40         cnt=0;
    41         dfs(1);
    42         printf("%d,",cnt);
    43     }
    44 } 
    我自倾杯,君且随意
  • 相关阅读:
    软件工程评分表
    评论
    团队成员介绍
    第九天冲刺
    第八天冲刺
    第七天冲刺
    第六天冲刺
    第五天冲刺
    第四天冲刺
    第三天冲刺
  • 原文地址:https://www.cnblogs.com/nicetomeetu/p/5533241.html
Copyright © 2011-2022 走看看