首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
搜索
推 荐
择校分析
笔经面经
学习交流
我要提问
站内公告
调剂专题
精彩爆料
解题报告
P1022
删除最大最小数 题解:
FengKeXiang
回复 0
|
赞 1
这题很坑!题目没有表述清楚,大部分同学应该通过率都是75%,就是还差了一种当序列中的最大值和最小值相同的时候,只需要输出一个这个相同的值就行了。 #include<iostream> #include<vector> #include<climits&g...
P1472
2048游戏 题解:简洁实现
qianqiangotoTHU
回复 1
|
赞 47
过了之后本来想看看有没有好玩的解法的,但是看到目前的题解都比较臃肿,要用100行以上代码实现,就打算分享一下自己的50+行代码的思路。 一、简洁实现四个方向 代码长主要是因为要实现四个方向的遍历,如果写四遍两层循环就巨麻烦 观察可以发现,只要对循环变量i j做一定的变换,就能...
P1963
中位数-ENCU 题解:
xujay
回复 0
|
赞 1
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; vector <int> A; for (int ...
P1185
全排列 题解:
jqt
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; &nbs...
P1261
字符串排序3 题解:C++ cin.ignore()关键
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; bool cStr(string s1,string s2){ if(s1.length()>s2.length()){ return true; }else{...
P1254
字符串排序 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ for(int i=0;i<s.length()-1;i++){ ...
P1026
删除字符串 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; string sShan(string s){ string s1; int l=0; while(l<s.length()){ if(s[l]=='g'&...
P1006
字符串翻转 题解:C++
苍灵
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; for(int i=s.length()-1;i>=0;i--){ cout<...
P1027
删除字符串2 题解:C++
苍灵
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; string sShan(string s){ string s1; int l=0; while(l<s.length()){ if((s[l]=='G'...
P1240
首字母大写 题解:C++ 关键在于空白符的判定(两种方法)
苍灵
回复 0
|
赞 4
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(getline(cin,s)){ if(s[0]>=97&&s[0]<=122){...
P1292
字母统计 题解:C++
苍灵
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ int num[25]={0}; for(int i=0;i<s....
P1012
字符移动 题解:C++
苍灵
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ int n=0,m=0; char num[120],lin[120]; string s; cin>>s; for(int...
P1014
加密算法 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ string s; getline(cin,s); for(int i=0;i<s.length();i++){ if(s[i]&g...
P1545
Aconly时间戳 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; struct data{ int y; int m; int d; int shi; int fen; int miao; }; int ma...
P1708
计算日期2 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; struct data{ int y; int m; int d; }; // 判断年份是否是闰年 bool isRun(data a){ if((a.y...
P1446
日期累加 题解:C++ 注意:本题需要考虑闰年
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; struct data{ int y; int m; int d; }; // 判断年份是否是闰年 bool isRun(data a){ if((a.y...
P1437
日期类 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; struct data{ int y; int m; int d; }; // 输出这个日期的后一天的日期(不考虑闰年) void mHou(data a)...
P1290
日期差值 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; struct data{ int y; int m; int d; }; // 将年月日由字符串类型转换为int类型 int mChange(string s...
P1566
确定比赛名次 (拓扑排序)题解:
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; const int maxn = 500 + 5; vector<int> v[maxn]; // 记录 i 指向的节点 int lev[maxn]; // 记录 ...
P1565
最短路 (Floyd算法)题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; const int maxn = 100 + 5; const int INF = 1e9; // 使用一个较大的数避免溢出 int mp[maxn][maxn]; int...
P1312
畅通工程 (kruskal + 并查集)题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; const int maxn = 100 + 5; struct node{ int u, v, w; }edge[maxn * maxn]; bool cmp(no...
P1969
输出柱状图 题解:
18919717626
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; &nbs...
P1051
日期计算 题解:C++ 50%正确率看这里
苍灵
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; struct data{ int y; int m; int d; }; // 判断月份和日是否合理 bool isTrue(data c){ if(c....
P1011
日期 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int y,d,sumD; cin>>y>>d; if(y==4){ sumD=d-12; }else{ ...
P1949
矩阵对角线的和 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int num[10][10]; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ ...
P1933
旋转矩阵 - 中南大学 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; // 矩阵逆时针旋转90度 void Ni90(int num[120][120],int n){ int num1[120][120]; for(int i=0;i&...
P1245
最大子矩阵 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ int num[120][120],max=-18000; for(int i=...
P1681
逃离迷宫 (bfs)题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int m, n; int k, x1, y1, x2, y2; char mp[105][105]; // 三维访问标记:x, y, 转弯次数 int vis[105][...
P1936
压缩日期 (采用位运算)题解:
cczz
回复 0
|
赞 3
#include<bits/stdc++.h> using namespace std; // 判断闰年 int isLeapYear(int y) { if(y % 400 == 0 || (y % 4 == 0 && y % 100 !=...
P1319
畅通工程 (并查集-路径压缩)模板题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int fa[1000 + 5]; int find(int x) { return x == fa[x] ? x : (fa[x] = find(fa[x])); ...
P1842
南京理工-女士优先 题解:答案等于最后一个F排到最终位置的时间,即至少由前面一个
武侠剧
回复 0
|
赞 1
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
P1828
西交-矩阵相加 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; while(cin>>n>>m){ int num1[120][120],num2[120][120...
P1531
求矩阵的鞍点 题解:C++
苍灵
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ int n,m; while(cin>>n>>m){ int num[12][12],flag=0; for(i...
P1407
矩阵最大值 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int m,n; while(cin>>m>>n){ int num[110][110]; for(int i=...
P1675
机器人走迷宫 题解:
jqt
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; char road[11][11]; int vis[11][11]; int w,h; int dir[4][4][2]={ -1,0,0,...
P1681
逃离迷宫 题解:
jqt
回复 0
|
赞 0
#include <bits/stdc++.h> using namespace std; struct node { int x, y; int times; int dirct; }...
P1681
逃离迷宫 题解:
jqt
回复 0
|
赞 0
#include <bits/stdc++.h> using namespace std; struct node { int x, y; int times; int dirct; }...
P1178
进制转换 题解:字符串解题:从高位开始往后走,将10倍转换成(2³+2¹)不断加
leo110
回复 0
|
赞 0
#include<iostream> #include<cstring> using namespace std; string Biadd(string s1,string s2){ string str; &nbs...
P1409
对称矩阵 题解:C++ 对称矩阵-关于主对角线对称
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ int num[101][101],flag=1; for(int i=0;i&...
P1543
矩阵位置 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int num[4][4],m=1; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ ...
P1384
矩阵幂 题解:80%正确率-看过来
苍灵
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; // 两个n*n的矩阵相乘 void Cheng(long long num1[20][20],long long num2[20][20],int n){ int l=0...
P1363
计算两个矩阵的乘积 题解:C++ 暴力(有点像)
苍灵
回复 0
|
赞 0
#include<iostream> using namespace std; int main(){ int num1[3][3],num2[3][3],num[2][2]; for(int i=0;i<2;i++){ for(int j=0;j&...
P1135
矩阵求和 题解:C++
苍灵
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n,num[100][100],sum[100]; cin>>n; for(int i=0;i<n;i++){ ...
P1024
二元组整数 题解:建议题例给出更具代表性的例子,要不然容易被重复这个词搞糊涂
leo110
回复 0
|
赞 0
/* 题目的意思是不允许一个int去构成一个二元组,必须是2个int; 其次构成的二元组不能重复,而不是说这两个int不能重复. 例如1,2,2,2这四个可以构成4x3=12...
P1567
Buyer 题解:回溯过程即可
武侠剧
回复 0
|
赞 0
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
P1479
01字符串 题解:
18919717626
回复 0
|
赞 3
在处理时面对下面2种情况,即f(n-1)+f(n-2) 保留第一个0不变,继续处理剩余的n-1个0 将前两个0压缩成1,继续处理剩余的n-2个0 #include <iostream> using namespace std; int f(in...
P5286
三个数的和 (双指针)题解:
cczz
回复 0
|
赞 0
#include<iostream> #include<cstdlib> #include<vector> #include<algorithm> using namespace std; int main(){ ...
P1924
层次遍历 (创建BST优化)题解:
cczz
回复 0
|
赞 1
#include<iostream> #include<cstdlib> #include<queue> #include<climits> // 用于INT_MAX using namespace std; typedef s...
P1798
数组排序 (stringstream分割)题解:
cczz
回复 0
|
赞 1
#include <iostream> #include <cstdlib> #include <vector> #include <string> #include <sstream> #include <alg...
P5278
找出字符串的最长回文子串(回文子串模板题) 题解:
cczz
回复 0
|
赞 0
中心扩展法: 回文串的长度都是奇数,我们称其为奇回文串, 例如 bcb。 回文串的长度都是偶数,我们称其为偶回文串, 例如 bccb。 比如子串 abccba,我们可以从头遍历每个字母,若是奇回文串,则将其视作中心点,若是偶回文串,则将其与其后面一位视为中心,...
1
2
我要提问
全站热榜
1
无法正确通过题目都是哪些原因造成的?
2
[置顶]计算机考研择校分析【25考研必读】
3
机试如何才能快速提高?
4
题目难点:数学公式不断化解
5
逻辑很简单,但是实现却要小心多多
6
【25计算机考研】39所985院校录取分数线汇总
7
A+B问题 题解:C
8
【23计算机考研】39所985院校录取分数线汇总
9
广度优先搜索计算每个人移动到每个位置需要去掉障碍物的最少数目,最后求和的最小值
10
1017 幂次方 快速幂模板