lanqiao 2114 李白打酒加强版 (朴素搜索)
This commit is contained in:
30
13lanqiao/test9-1.cpp
Normal file
30
13lanqiao/test9-1.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// lanqiao 2114 李白打酒加强版 (朴素搜索)
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int mod = 1e9+7;
|
||||
int n, m, ans;
|
||||
void dfs(string str, int cur_n, int cur_m, int dep, int sum){
|
||||
if(cur_n > n + 1 || cur_m > m + 1 || dep > n + m + 1) return;
|
||||
if(cur_n == n + 1 && cur_m == m + 1 && dep == n + m + 1 && sum == 0 && str[str.size() - 1] == '0'){
|
||||
ans++;
|
||||
ans %= mod;
|
||||
// cout << str << endl;
|
||||
return;
|
||||
}
|
||||
// 枚举方案
|
||||
for(int i = 0; i <= 1; i++){
|
||||
if(i == 1) dfs(str + to_string(i), cur_n + 1, cur_m, dep + 1, sum * 2);
|
||||
if(i == 0 && sum) dfs(str + to_string(i), cur_n, cur_m + 1, dep + 1, sum - 1);
|
||||
}
|
||||
}
|
||||
|
||||
int main(){
|
||||
cin >> n >> m;
|
||||
string emp;
|
||||
dfs(emp, 1, 1, 1, 2);
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
||||
/* test samples -> 14
|
||||
5 10
|
||||
*/
|
||||
Reference in New Issue
Block a user