首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
18919717626
这个人很懒,什么都没有写...
关注
发消息
文章
20
题解
48
发帖
0
笔记
22
Ta的粉丝
19
关注数
1
粉丝数
19
获赞数
375
阅读数
44928
简单的背包问题 题解:01背包的变式
首先我们来看标准的01背包问题 有 N 件物品和一个容量是 V 的背包。每件物品只能使用一次。 第 i件物品的体积是 vi,价值是 wi 求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。 输出最大价值。 输入格式 第一行两个整数,...
P5129
2024年6月29日 13:42
回复 0
|
赞 34
|
浏览 1.4k
奇数还是偶数 题解:不用解释
#include <iostream> using namespace std; int main(){ int n; cin >> n; if(n % 2 == 1){ cout << "odd number" &l...
P2007
2024年6月28日 21:47
回复 0
|
赞 3
|
浏览 869
括号匹配的问题 题解:栈 + 简单判断
#include <iostream> #include <stack> using namespace std; int main(){ string s; cin >> s; stack<char> st; ...
P4933
2024年6月28日 21:39
回复 0
|
赞 10
|
浏览 870
单词翻转 题解:栈:先进后出 + 单词分离
本题的特性就是先输入的单词最后输出,还伴随着识别单词的过程,可以使用数据结构栈进行解题 #include <iostream> #include <stack> using namespace std; int main(){ stack&l...
P3666
2024年6月28日 21:27
回复 0
|
赞 15
|
浏览 916
字符串替换 题解:find + replace详细版
字符串函数处理比较简单,双指针容易错,find(字符串)是返回该字符串在原字符串的下标,replace()的三个参数是需要替换的下标、被替换字符串的长度、新的字符串 string& replace (size_t pos, size_t len, const string&a...
P2011
2024年6月28日 20:55
回复 0
|
赞 18
|
浏览 916
找出众数 题解:方法一:正常数组+方法二:MAP runtime超时大部分是数组小了
map容器进行遍历 #include <iostream> #include <map> using namespace std; int main(){ map<int,int> mymap; int n,m; c...
P2014
2024年6月28日 20:24
回复 0
|
赞 15
|
浏览 983
三角形判定 题解:sort排序简化代码
#include <iostream> #include <algorithm> using namespace std; int main(){ int n; int a[1...
P2018
2024年6月28日 19:44
回复 0
|
赞 12
|
浏览 853
整数去重 题解:最清楚版
m的一开始没有看数组的范围,少看了一个0,本来想用B数组作为复制的,结果直接输出可以ac #include <iostream> #include <string.h> using namespace std; const int N = 2e4 +...
P2021
2024年6月28日 19:34
回复 0
|
赞 18
|
浏览 1.9k
1
2
3
本科学校:苏州大学
目标学校:苏州大学
点此申请N诺身份认证
获得 noobdream 认证,享受多重认证福利!