主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
发布
搜索
推 荐
择校分析
笔经面经
学习交流
我要提问
站内公告
调剂专题
精彩爆料
解题报告
P2014
找出众数 题解:c++实现,set去重,count计算出现次数
Cookie‘s AE86
回复 0
|
赞 0
|
浏览 181
#include<bits/stdc++.h> using namespace std; int main (){ int n, tmp; cin >> n; set<int> myset; int arr...
P2011
字符串替换 题解:C++ find()、replace()实现
Cookie‘s AE86
回复 0
|
赞 0
|
浏览 174
#include<bits/stdc++.h> using namespace std; int main (){ string s; cin >> s; transform(s.begin(), s.end(),s.begin...
P2021
整数去重 题解:注意n的取值范围,时间复杂度不能高于O(nlogn),所以不能直
Cookie‘s AE86
回复 0
|
赞 0
|
浏览 254
#include<bits/stdc++.h> using namespace std; int main(){ int n, tmp; while(cin >> n){ int arr[n]; int...
P1097
负二进制 题解:看了大佬的解释
122793160
回复 0
|
赞 0
|
浏览 238
#include<bits/stdc++.h> using namespace std; int main(){ int m; while(cin>>m){ ...
P1375
素数 题解:C语言
渐鸿于陆
回复 0
|
赞 0
|
浏览 412
#include<stdio.h> #include<math.h> #include<string.h> int arr[105]; int main(void){ int n;  ...
P1180
最简真分数 题解:算法上感觉对了,但是AC不了
williams
回复 6
|
赞 0
|
浏览 253
#include <stdio.h> #include <stdbool.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <...
P1088
不简洁
yanmy
回复 0
|
赞 0
|
浏览 134
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; struct Student { ...
P1254
字符串排序 题解:
潇风青禾
回复 0
|
赞 0
|
浏览 164
#include<bits/stdc++.h> using namespace std; int main(){ char s[20]; gets(s); sort(s, s+strlen(s)); puts(s); return 0; } ...
P1475
大整数乘法 题解:Python大法好
Śś
回复 0
|
赞 0
|
浏览 147
while True: try: n = input() a = input() b = ...
P1156
质因数个数 题解:
今夕何夕12211
回复 0
|
赞 0
|
浏览 189
q求助 显示超时 准确率只有75% #include <stdio.h> #include <stdlib.h> #include <string.h> int isprime(int n) { int sqt=s...
P1375
素数 题解:
今夕何夕12211
回复 3
|
赞 0
|
浏览 156
为什么一直是50% #include <stdio.h> #include <stdlib.h> #include <string.h> int isprime(int n) { int sqt=sqrt(n); ...
P1375
素数 题解:简单易懂
Śś
回复 0
|
赞 0
|
浏览 143
#include<iostream> #include<math.h> using namespace std; int Judge(int x) { if(x<2)return 0; ...
P1401
递归大法
老猫
回复 1
|
赞 7
|
浏览 7.7k
1、前序遍历的第一元素是整个二叉树的根节点 2、中序遍历中根节点的左边的元素是左子树,根节点右边的元素是右子树 3、后序遍历的最后一个元素是整个二叉树的根节点 #include <iostream> #include <string> #inc...
P1414
回文字符串 题解:C++ 指针
Griffies
回复 0
|
赞 0
|
浏览 161
#include <iostream> #include <algorithm> #include <cstring> using namespace std; int main(){ char s1[1005]; ...
P1009
随机数 题解:挑战最短代码
williams
回复 5
|
赞 3
|
浏览 884
#include <stdio.h> int main(){ printf("210"); }
P1565
1565 最短路 Dijkstra+去重边
青缘
回复 1
|
赞 4
|
浏览 5.4k
这题本质上就是经典的朴素Dijkstra算法 使用 G[MAXN][MAXN]邻接矩阵表示图 vis[MAXN]表示点是否被标记 dis[MAXN]表示源点到点i的最短距离 pre[MAXN]表示点i的前向点 根据Dijkstra算法,进行迭代即可。 ...
P1156
质因数个数
零壹
回复 1
|
赞 2
|
浏览 1.9k
注意这几点: 1.判断质数判断到sqrt就行,这样可以节省一半时间; 2.为了解决有多个重复因数的情况,每次都让i=2. #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<...
P1461
反序相等 题解:
Amberqwe
回复 2
|
赞 0
|
浏览 116
为啥在其他测试通过,这个不通过 #include <stdio.h> #include <string.h> int main() { for (int i = 1000; i < 1200;...
P1015
单链表 题解:我这个怎么不对,先把输入的数排序,然后用头插法插进链表,奔溃啊
张会老儿
回复 1
|
赞 0
|
浏览 237
#include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> #include<stdlib.h> using namespace...
P2012
堆排序 题解:c++ 小根堆
damowanghwj
回复 0
|
赞 0
|
浏览 176
#include<bits/stdc++.h> using namespace std; priority_queue<int,vector<int>,greater<int>> pQue; int main(){ i...
P1899
十进制加密 题解:
williams
回复 0
|
赞 0
|
浏览 125
#include <stdio.h> #include <stdbool.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <...
P1490
思路是用-1替换0,然后用前缀和的思想。主要的技巧是用map存begin,刚开始
Ang
回复 1
|
赞 0
|
浏览 9.4k
#include<bits/stdc++.h> using namespace std; int main(){ string str; while(cin>>str){ map<int,int> m; ...
P1233
二叉树 题解:
Cookie‘s AE86
回复 0
|
赞 0
|
浏览 123
#include<bits/stdc++.h> using namespace std; int main(){ int x,y; while(cin >> x >> y){ while(x != y){ ...
P1225
谁是你的潜在朋友 题解:
Amberqwe
回复 1
|
赞 0
|
浏览 134
爲什麽beiju輸不出來 #include <stdio.h> int main() { int a, b, c[200]; scanf("%d %d\n", &...
P1375
素数 题解:
Amberqwe
回复 2
|
赞 0
|
浏览 166
为什莫一直是百分之50 #include<stdio.h> #include<math.h> int main() { int n,k=0; while(scanf("%...
P1410
打印日期 题解:只有60% ,求大佬提点
OIsay-good
回复 2
|
赞 0
|
浏览 305
#include<stdio.h> struct node { int year,month,day,x; }p; int s[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; ...
P1413
N阶楼梯上楼问题 题解:c语言解 。 要注意数量大了之后就超出int的范围了,要
orderrr
回复 0
|
赞 0
|
浏览 184
#include <stdio.h> int f(int x) { if (x == 0 || x == 1) { return 1; } else { return f(x - 1)...
P1562
哈夫曼编码 题解:c++优先队列实现,注意全为同一字符的特殊情况,例如:BBBB
Cookie‘s AE86
回复 0
|
赞 0
|
浏览 191
#include<bits/stdc++.h> using namespace std; void func(string s){ int len = s.size(); set<char> myset; for(int i =...
P1417
八进制 题解:为什么通过率只有百分之八十
八千
回复 7
|
赞 0
|
浏览 382
#include<bits/stdc++.h> using namespace std; int main(){ int n, a; scanf("%d", &n); ...
P1111
斐波那契数列 题解:两种思路
孙某人
回复 0
|
赞 0
|
浏览 231
1.直接 unsigned long long ,适合求位数小的 #include <iostream> #include <string.h> using namespace std; int main(){ unsigned long l...
P1334
最大连续子序列 题解:基于动态规划 思路:先找出最大子序列的结尾然后倒推
中国人民万岁
回复 4
|
赞 0
|
浏览 259
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { &nb...
P1477
set或map
Mihara
回复 1
|
赞 1
|
浏览 4.7k
法1. STL中的unordered_set容器类(也可以用set)非常适合解决这个问题。 对于unordered_set: 其查找操作和插入操作的时间复杂度都是O(1) #include <iostream> #include <set> ...
P1392
杨辉三角形 - 西北工业大学 题解:之前没敲出来 过了半个月顿悟了
williams
回复 0
|
赞 0
|
浏览 260
#include <stdio.h> int main(){ int num,c[100][100]; scanf("%d",&num); c[1][1]=1; for(int i=1;i<num;i++) c[i][0]=1; for(...
P1445
直角三角形 题解:
xcc7777776686
回复 0
|
赞 0
|
浏览 145
#include<stdio.h> #include<math.h> #include<stdlib.h> #include<stdbool.h> int main(){ int x1,x2; &...
P1880
上古计算机 题解:
zxd12363
回复 0
|
赞 0
|
浏览 113
#include<bits/stdc++.h> using namespace std; int main() { map<string, int>m; string s;  ...
P1017
幂次方 题解:运用二分快速幂思想和同余模定理即可。
damowanghwj
回复 0
|
赞 0
|
浏览 281
#include<bits/stdc++.h> using namespace std; long long x,n; const int N = 233333; long long pow(long long n){ long long ans = 1...
P1018
击鼓传花 题解:队列解题
gzulianxisheng
回复 0
|
赞 0
|
浏览 312
#include <bits/stdc++.h> using namespace std; int main(){ queue<int> Q; int n; &nb...
P1011
日期 题解:
zwl__rank
回复 0
|
赞 0
|
浏览 319
//今天是2012年4月12日星期四,编写程序, //输入今天开始到12月31日之间的任意日期,输出那一天是星期几。 //例如输入“5(回车)20(回车)”(5月20日),输出应为“Sunday”。 //输入第一行为月份。 //输入第二行...
P1024
二元组整数 题解:已AC
damowanghwj
回复 1
|
赞 0
|
浏览 295
#include<bits/stdc++.h> using namespace std; struct Point{ int a; int b; bool operator < (const Point &po) const{...
P1023
IP地址 题解:判断点的个数以及每个位置是不是数字 且数字范围是不是正确
damowanghwj
回复 0
|
赞 0
|
浏览 220
#include<bits/stdc++.h> using namespace std; string trans(int n){//10进制转16进制 string s = ""; int num = 2; while(num--){ ...
P1179
密码翻译 题解:
huanghu
回复 0
|
赞 0
|
浏览 140
#include<iostream> #include<string> using namespace std; int main(){ string str; while(getline(cin,str)){ int len = str.l...
P1881
安全驾驶 题解:
zxd12363
回复 0
|
赞 0
|
浏览 115
//最后一辆想要安全到达,则需保证不能和其他车相遇,则最后一辆行驶的时间一定小于其他所有车辆行驶时间,只需算出其他车的平均用时,找出用时最长的,用最后一辆车到终点的距离除以该时间即可。 include<bits/stdc++.h> using namespace std; ...
P1212
平方和与立方和 题解:
huanghu
回复 0
|
赞 0
|
浏览 127
#include<iostream> using namespace std; int main(){ int m,n; while(cin>>m>>n){ int sumji = 0; int sumou = 0; i...
P1021
复数 题解:c++struct 和 运算符重载实现
damowanghwj
回复 0
|
赞 0
|
浏览 136
#include<bits/stdc++.h> using namespace std; struct Complex{ double real; double image; Complex operator + (const Complex ...
P1240
首字母大写 题解:好奇怪,同样的数据,dev运行出来的结果就是对的,怎么复制过来
渐鸿于陆
回复 1
|
赞 0
|
浏览 647
#include<stdio.h> #include<string.h> char s[105]; int main(void){ while(gets(s)){ &nbs...
P1798
数组排序 题解:c++ 复杂
huanghu
回复 0
|
赞 0
|
浏览 169
#include <iostream> #include <vector> #include<string> #include<algorithm> using namespace std; int main(){ st...
P1264
二叉树2 题解:为什么可以用int啊,题目的不是说的小于10亿吗,
张会老儿
回复 1
|
赞 0
|
浏览 161
05555555
P1161
二叉树遍历 题解:大佬,帮我看看,我这个怎么不对啊。
张会老儿
回复 2
|
赞 0
|
浏览 253
#include<bits/stdc++.h> using namespace std; # typedef struct node{ char data; struct node *lchi...
P1735
统计卡牌的值 题解:
zxd12363
回复 0
|
赞 0
|
浏览 113
#include<bits/stdc++.h> using namespace std; int main() { int n; while (scanf("%d", &...
P1001
01序列 题解:输出0-63的六位二进制即可
damowanghwj
回复 0
|
赞 0
|
浏览 277
#include<bits/stdc++.h> using namespace std; string trans(int n){ string s = ""; for(int i = 0; i < 6;i++){ ...
P1905
整数排序 题解:
zxd12363
回复 0
|
赞 0
|
浏览 112
#include <bits/stdc++.h> using namespace std; int count(int n) { int count = 0; while (n != 0) &n...
P1033
细菌的繁殖 题解:c语言
orderrr
回复 0
|
赞 0
|
浏览 140
#include <stdio.h> int main() { int m; scanf("%d", &m); while (m > 0) { int x; scanf("%d",...
P1658
上楼梯 题解: 动态规划
huanghu
回复 0
|
赞 0
|
浏览 242
#include <iostream> #include <vector> #include<string> #include<algorithm> using namespace std; int dp[1005] = {0}...
P1843
天津大学-进制转换 题解:C 直接printf即可
huanghu
回复 0
|
赞 0
|
浏览 142
#include<stdio.h> int main(){ int n; scanf("%d",&n); printf("%o\n",n); return 0; } 方法二 #inclu...
P1123
小偷的背包 题解:组合数问题,回溯法直接套模板就行
CGaaraY
回复 0
|
赞 0
|
浏览 157
#include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; int weight[10000]; ...
P1016
字符分类 题解:挺适合拿来练习结构体的应用哒。
Djiangxu
回复 0
|
赞 0
|
浏览 194
解题思路: (1)有三种类型的字符需要分类,我们可以定义三个数组,为了避免某一种类型的字符数量可能独占100,所以需要将定义的三个类型的数组长度设置为100; (2)定义完数组后,还需要用一个变量来记录数组下标,表示归类长度,用于输出; (3)判断输入字符类型,第一类是字母,...
P1051
日期计算 题解:有人能看看为啥ac50%吗
渐鸿于陆
回复 4
|
赞 0
|
浏览 257
#include<stdio.h> struct node{ int year; int month; int day; }p; int main(vo...
P1393
矩阵转置 题解:
huanghu
回复 0
|
赞 0
|
浏览 149
#include <iostream> #include <vector> #include<string> #include<algorithm> using namespace std; int arr[100][100...
P1081
猴子报数 题解:自用笔记(C语言)
zx142407789
回复 0
|
赞 0
|
浏览 136
猴子报数(击鼓传花)用不带头结点的循环链表 #include<stdio.h> #include<stdlib.h> typedef struct Node { int data; struct Node* next; }node,*LinkLi...
P1018
击鼓传花 题解:非链表版
我爱陈少熙
回复 0
|
赞 0
|
浏览 161
#include <iostream> #include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d&q...
我要提问
近期热门
1
N诺成就值出炉,帮你一眼识别大神
2
机试如何才能快速提高?
3
[置顶]计算机考研择校分析【25考研必读】
4
广度优先搜索计算每个人移动到每个位置需要去掉障碍物的最少数目,最后求和的最小值
5
1377旋转矩阵
6
ip地址(C)
7
简单易懂
8
C++递归解法,有注释
9
1017 幂次方 快速幂模板
10
计算机考研复试笔记——操作系统篇