9 条题解
-
2
#include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <exception> #include <fstream> #include <functional> #include <limits> #include <list> #include <map> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <utility> #include <vector> #include <cwchar> #include <cwctype> #include <complex.h> #include <fenv.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <tgmath.h> #include <string.h> #include <math.h> #include <stdio.h> #define int long long using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int n,m,sum; bool sb[N]; void dfs(int s,int a) { if(a==0) { sum++; return; } if((n-s+1)/2<a) return; for(int i=s+2;i<=n;i++) { if(sb[i]==0) { sb[i]=1; dfs(i,a-1); sb[i]=0; } } } signed main() { cin>>n>>m; dfs(-1,m); cout<<sum; return 0; }
-
2
#include<bits/stdc++.h> #define int long long using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int n,m,ans; bool v[N]; void dfs(int num,int c){ if(c==0){ ans++; return; } if((n-num+1)/2<c){ return; } for(int i=num+2;i<=n;i++){ if(v[i]==0){ v[i]=1; dfs(i,c-1); v[i]=0; } } } signed main(){ cin>>n>>m; dfs(-1,m); cout<<ans; return 0; }
-
1
#include<iostream> using namespace std; const int MAXN = 1e5 + 10; int n,m,ans; void f(int n,int m) { if (n / 2 + 1 < m) { return ; } if (m == 0) { ans++; return ; } for (int i = n;i >= 1;i--) { f(i - 2,m - 1); } } int main() { cin >> n >> m; f(n,m); cout << ans << endl; return 0; }
-
-2
#include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int n,m,ans; void f(int last,int step) { if(last/2+1<step) return; if( 0 == step) { ans++; return ; } for(int i =last;i >=1;i--) f(i-2,step - 1); } int main() { cin >> n >> m; f(n,m); cout<< ans<<endl; return 0; }
-
-2
/***************************************** 备注: ******************************************/ #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int n,m,ans; void f(int last,int step) { if(last/2+1<step) return; if(0==step) { ans++; return; } for(int i=last;i>=1;i--) f(i-2,step-1); } int main() { cin>>n>>m; f(n,m); cout<<ans<<endl; return 0; }
-
-2
C++
#include <iostream> #include <stdio.h> #include <string.h> #include <queue> #include <math.h> #include <vector> #include <algorithm> #include <iomanip> #include <stack> using namespace std; #define LL long long const int N =1e5+10; const int INF =0x3f3f3f3f; int n,m,ans; void f(int last ,int step){ if(last/2+1<step) return; if(0== step){ ans++; return; } for(int i=last;i>=1;i--) f(i-2,step-1); } int main(){ cin>>n>>m; f(n,m); cout<<ans<<endl; return 0; }
-
-2
C++ #include <iostream> #include <stdio.h> #include <string.h> #include <queue> #include <math.h> #include <vector> #include <algorithm> #include <iomanip> #include <stack> using namespace std; #define LL long long const int N =1e5+10; const int INF =0x3f3f3f3f; int n,m,ans; void f(int last ,int step){ if(last/2+1<step) return; if(0== step){ ans++; return; } for(int i=last;i>=1;i--) f(i-2,step-1); } int main(){ cin>>n>>m; f(n,m); cout<<ans<<endl; return 0; }
-
-2
/***************************************** 备注: ******************************************/ #include <queue> #include <math.h> #include <stack> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include <algorithm> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int n,m,ans; void f(int last,int step) { if(last/2+1<step) return; if(0==step) { ans++; return; } for(int i=last;i>=1;i--) f(i-2,step-1); } int main() { cin>>n>>m; f(n,m); cout<<ans<<endl; return 0; }
- 1
信息
- ID
- 1484
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 264
- 已通过
- 88
- 上传者