DFS,最优解 解题思路:本题可以用dij算法,但是我感觉dfs更好想,要求最短路径,用递归的话,如果去第2个城市,之前已经去过了,再去一边结果是相同的,所以最优解就是每个城市只去一次,用boolf[N]来判断,然后经行在dfs中加上回溯,即可注意事项:设置ans时用0x3f3f3f3f这个最大值容易超时;参考代码: 题解列表 2024年04月12日 0 点赞 1 评论 662 浏览 评分:6.0
信息学奥赛一本通TT1262-挖地雷 摘要:解题思路:DP 逆推, 邻接矩阵注意事项:参考代码:#include<iostream> #include<algorithm> using namespace std; const int N…… 题解列表 2024年04月16日 0 点赞 0 评论 502 浏览 评分:6.0
究极空间换时间之无脑枚举 摘要:解题思路:注意事项:参考代码:#include<bits/stdc++.h>using namespace std;const int N=1e5+10;int a0[N],a1[N],a2[N],a…… 题解列表 2024年04月16日 0 点赞 0 评论 655 浏览 评分:6.0
python--study||O.o 摘要:参考代码:# 重点就是判断条件的顺序 n = int(input()) square = [[0] * (2 * n - 1) for _ in range(2 * n - 1)] x, y…… 题解列表 2024年04月19日 0 点赞 0 评论 503 浏览 评分:6.0
3044: 电池的寿命 摘要:解题思路:注意事项:参考代码:#include<iostream> #include<algorithm> #include<utility> #include<limits> #inclu…… 题解列表 2024年04月20日 0 点赞 0 评论 583 浏览 评分:6.0
2804: 与指定数字相同的数的个数 摘要:解题思路:注意事项:千万别抄,会遭报应的参考代码:#include <iostream>using namespace std;typedef long long ll;const int N=1e7…… 题解列表 2024年04月21日 1 点赞 0 评论 570 浏览 评分:6.0
[递归]母牛的故事(动态规划,递归) 摘要:解题思路:写出数学表达式 F(x){ x<=3 f(x)=x;// 前三年只有一头母牛生孩子 &nbs 题解列表 2024年04月27日 0 点赞 0 评论 627 浏览 评分:6.0
编写题解 1035: [编程入门]自定义函数之字符类型统计 摘要:解题思路:注意事项:参考代码:#include<stdio.h> #include<stdlib.h> #include<string.h> void count(char* str,int* …… 题解列表 2024年05月13日 0 点赞 0 评论 485 浏览 评分:6.0
求长方形面积 摘要:参考代码:#include<stdio.h>int main(){ int a,b; int C=0,S=0; scanf("%d%d",&a,&b); C=2*(a+b); S=a*b; print…… 题解列表 2024年05月24日 0 点赞 1 评论 1293 浏览 评分:6.0
测试数据有问题 摘要:错误样例样例:33 1 0预期:2实际:3注意事项:参考代码:贴上代码:right方法是错误的import java.util.Arrays; import java.util.Random; i…… 题解列表 2024年05月30日 2 点赞 0 评论 765 浏览 评分:6.0