| 比赛 |
2026初中综合小练习 |
评测结果 |
TAAAAAATTT |
| 题目名称 |
传球游戏 |
最终得分 |
60 |
| 用户昵称 |
LHS28_ |
运行时间 |
5.979 s |
| 代码语言 |
C++ |
内存使用 |
3.63 MiB |
| 提交时间 |
2026-04-14 20:35:41 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
void dfs(int idx,int depth){
if (depth == m){
if (idx == 1) ans++;
return;
}
if (idx == n) dfs(1,depth+1);
else dfs(idx+1,depth+1);
if (idx == 1) dfs(n,depth+1);
else dfs(idx-1,depth+1);
return;
}
int main(){
freopen("ballg.in","r",stdin);
freopen("ballg.out","w",stdout);
scanf("%d%d",&n,&m);
dfs(1,0);
cout<<ans;
return 0;
}