蓝桥杯算法训练VIP-传球游戏-题解(c++代码)(dfs + 剪枝) 解题思路:由于每次传递都只能向左右传递一个单位,所以我们可以根据此特性画出下图所示二叉树(从0开始传递,一共3人传递3次)。接下来我们可以用dfs找出值为0的叶子结点数(即为球传递回0的次数),最后再用剪枝优化代码,即可AC注意事项:参考代码:#includeusingn 题解列表 2024年03月03日 0 点赞 0 评论 724 浏览 评分:9.9
去掉余数为2的数即可 关键在于,如何判断某个数是不是平方差```c++#includeusingnamespacestd;boolfunction(intx){boolres=false;if(x%2==1&&x>=3)res=true;if(x>=8&&x%4==0)res=true;returnres;}intmain 题解列表 2024年03月03日 0 点赞 0 评论 560 浏览 评分:0.0
找规律找规律 摘要:解题思路:注意事项:参考代码:#include<bits/stdc++.h>using namespace std;int main(){ int n,m; cin >> n >> m; int a[…… 题解列表 2024年03月03日 0 点赞 0 评论 456 浏览 评分:0.0
3009: 判断闰年 摘要:解题思路:闰年两种判定方法:要么能被4整除且不能被100整除,或者能被400整除可得参考代码:#include<iostream> using namespace std; int main() …… 题解列表 2024年03月03日 0 点赞 0 评论 625 浏览 评分:0.0
贪心算法——C 填充 摘要:解题思路:将字符'?'当作一个万能字符(就是为?就成为一个字串),上代码注意事项:参考代码:#include <stdio.h>#include <string.h>char a[10…… 题解列表 2024年03月03日 0 点赞 0 评论 692 浏览 评分:0.0
快速排序(C++) 摘要:#include<iostream> using namespace std; int arr[100000]; int getpivot(int left, int right) { i…… 题解列表 2024年03月03日 0 点赞 0 评论 805 浏览 评分:9.9
复习排序(本题用最后一种方法,前几个也可以) 摘要:解题思路:注意事项:参考代码:#include<bits/stdc++.h>using namespace std;int main(){ int n; cin >> n; int a[n],i=-1…… 题解列表 2024年03月03日 0 点赞 0 评论 427 浏览 评分:0.0
归并排序(C++) 摘要:解题思路:注意事项:参考代码:#include<iostream> using namespace std; const int N = 1e5 + 10; int arr[N],tmp[N],…… 题解列表 2024年03月03日 0 点赞 0 评论 870 浏览 评分:6.0
编写题解 1120: C语言训练-"水仙花数"问题2 摘要:解题思路:list comprehension注意事项:参考代码:[print(f'{b*100+s*10+g}') for b in range(1,10) for s in ran…… 题解列表 2024年03月03日 0 点赞 0 评论 448 浏览 评分:0.0
三国游戏 贪心算法 #三国游戏n=int(input())a=list(map(int,input().split()))b=list(map(int,input().split()))c=list(map(int,input().split()))defsjfs(country, 题解列表 2024年03月03日 0 点赞 0 评论 1325 浏览 评分:9.3