自然数的拆分(递归法) 摘要:解题思路:采用vector记录拆分路径,枚举可能拆分的数值,借助push_back(),pop_back()方法,动态记录结果,并输出注意事项:参考代码://自然数拆分#include <bit…… 题解列表 2025年07月20日 0 点赞 0 评论 9 浏览 评分:0.0
dfs求解自然数的拆分 摘要: #include using namespace std; int n,a[50];//a用来存储分割结果 void dfs(int t) { if (!t && a[0] …… 题解列表 2025年03月04日 0 点赞 0 评论 398 浏览 评分:0.0
最简自然数的拆分 摘要:参考代码:#include <iostream> #include <stdlib.h> #include <stdio.h> #include <string.h> using namesp…… 题解列表 2024年11月30日 0 点赞 0 评论 490 浏览 评分:9.9
dfs简单易懂--来自蒟蒻的题解 摘要:# 欢迎各位赏脸来看本蒟蒻的题解 ~~保姆级教程~~(不是) 一眼dfs 但是可能会遇到重复加的问题 导致答案错误 ##### 其实只要 思考一下dfs递归的本质 就会发现 只需要加一个 特判就可…… 题解列表 2024年09月12日 0 点赞 1 评论 592 浏览 评分:8.0
基础的递归拆分输出 摘要:解题思路:注意事项:参考代码:#include <bits/stdc++.h>using namespace std;#define endl '\n'#define int long…… 题解列表 2024年04月18日 0 点赞 0 评论 226 浏览 评分:0.0
编写题解 3034: 自然数的拆分(DFS) 摘要:解题思路:1,首先,定义了一个名为dfs的函数,该函数接受一个参数u,表示当前节点的值。2,在dfs函数内部,首先判断u是否等于0且路径长度大于1。如果满足条件,说明已经找到了一条满足条件的路径,将路…… 题解列表 2024年03月13日 0 点赞 0 评论 526 浏览 评分:8.0
题目 3034: 自然数的拆分 摘要:算法介绍: 本题使用的算法为深度优先搜索算法(Depth-First-Search,DFS),该算法所遵循的策略如同名字一样,讲究一个“深”字,就是尽可能深的去搜锁所有的节点,直到把所有…… 题解列表 2023年11月26日 0 点赞 0 评论 446 浏览 评分:7.3
DFS+递归(这题花费我太长时间,仅仅留做纪念,刚接触,大佬勿喷!!!) 摘要:解题思路:DFS注意事项:以后的每一项都要比当前的数大参考代码:#include<iostream>using namespace std;int n;int a[100]={1};void dfs(…… 题解列表 2023年11月13日 0 点赞 4 评论 388 浏览 评分:8.0
不重复输出的关键是,前面的数比后面的大 摘要:n=int(input())t=ndef rec(n,res): if n<1: if len(res)==1: return for k,x …… 题解列表 2023年10月26日 0 点赞 0 评论 512 浏览 评分:7.3
自然数的拆分(dfs) 摘要:解题思路:注意事项:参考代码:#include<iostream> #include<cstring> using namespace std; const int N=10010; int …… 题解列表 2023年08月12日 0 点赞 0 评论 768 浏览 评分:7.3