文章分类 -  算法练习

摘要:#include <stdio.h> int a=5,b=0,c=0,times=0; void move(char start,char end,int n) { if(end=='c') c++; else if(end=='b') b++; else if(end=='a') a++; if( 阅读全文 »
posted @ 2022-10-08 22:15 TCcjx 阅读(26) 评论(0) 推荐(0) 编辑
摘要:本题分析总结: 将大问题划分称为小问题,得到递推方程 dp[i] = max(dp[i-1],dp[i-2]+value[i]) 从而思路进行转变,不再去分析 局部如何使结果达到最优,而是从整体上去考虑最优结果 #题解代码 #include <stdio.h> int main() { int ar 阅读全文 »
posted @ 2022-08-23 14:41 TCcjx 阅读(16) 评论(0) 推荐(0) 编辑
摘要:快排代码 #include <iostream> #include <cstdio> using namespace std; int a[100005],n; void quick_sort(int l,int r) { int i=l,j=r,flag = a[l+r>>1]; do{ whil 阅读全文 »
posted @ 2022-04-08 18:14 TCcjx 阅读(36) 评论(0) 推荐(0) 编辑
摘要:快排的基本思想就是二分,理解了其实就不难,之前看了y总的板子,我觉得洛谷的更容易理解一点。 #include <iostream> using namespace std; int a[110000]; void quick_sort(int a[],int l,int r){ int i=l,j= 阅读全文 »
posted @ 2022-04-08 15:57 TCcjx 阅读(40) 评论(0) 推荐(0) 编辑
摘要:1.计数排序 计数排序读入选票并统计的时间复杂度是O(m),输出选票的时间复杂度为O(m+n),空间复杂度为O(n),因此计数排序只能用于排序编号范围不是很大的数字。 #include <iostream> using namespace std; int a[1010],n,m,tmp; int 阅读全文 »
posted @ 2022-04-08 14:43 TCcjx 阅读(30) 评论(0) 推荐(0) 编辑
摘要:题目链接 (手动点击跳转) 题目分析:同样是高精度模拟的题 #include <iostream> #include <cstring> using namespace std; #define maxn 5020 int a[maxn],b[maxn],c[maxn]; int main() { 阅读全文 »
posted @ 2022-03-12 11:27 TCcjx 阅读(45) 评论(0) 推荐(0) 编辑
摘要:题目链接 (手动点击跳转) #下面是正文 题目背景:先总结一下常用的数据类型 1.char(一字节,八位) -128127 2.int(四字节,三十二位) -2^31-231-1,大约能够表示绝对值不超过2.1x109的整数 3.unsigned int(四字节,三十二位) 0232-1大约能够表示 阅读全文 »
posted @ 2022-03-12 10:30 TCcjx 阅读(31) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏