一时暴搜一时爽 一直暴搜一直爽  cxl居然和我写的同款dfs,天呢【luogu1472】 奶牛家谱 Cow Pedigrees [动态规划]

菜鸡开始对这题并没有什么想法 状态方程死活想不出来 还是暴搜好

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 #define rg register
 5 const int N=200,K=100,P=9901;
 6 int n,k,f[K+5][N+5],ans=0;
 7 template <class t>void rd(t &x)
 8 {
 9     x=0;int w=0;char ch=0;
10     while(!isdigit(ch)) w|=ch=='-',ch=getchar();
11     while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
12     x=w?-x:x;
13 }
14 
15 void dfs(int deep,int l,int r)
16 {
17     if(deep==k&&(l+r+1)==n) {++ans;ans%=P;return;}
18     if((l+r+1>=(1<<deep))||deep>k) return;
19     dfs(deep+1,l,r+2);dfs(deep+1,l+2,r);
20     dfs(deep,l+2,r);dfs(deep,l,r+2);
21 }
22 
23 int main()
24 {
25     freopen("nocows.in","r",stdin);
26     freopen("nocows.out","w",stdout);
27     rd(n),rd(k);
28     if(n==(1<<k)-1) {printf("1");exit(0);}
29     dfs(2,1,1);
30     printf("%d",ans);
31     return 0;
32 }
16昏 搜索

相关文章:

  • 2021-08-17
  • 2021-09-23
  • 2021-08-14
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-12-07
  • 2021-07-21
  • 2022-02-22
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2021-05-17
相关资源
相似解决方案