自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 收藏
  • 关注

原创 lc双指针(数组移除元素)JS

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一、pandas是什么? 二、使用步骤 1.引入库 2.读入数据 总结 前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。 提示:以下是本篇文章正文内容,下面案例可供参考 一、pandas是什么? 示例:pandas 是基于NumPy 的一种工具,该工具是为...

2022-05-01 11:07:32 287

原创 二分搜索(JS)

总结:数组为有序数组,同时题目还强调数组中无重复元素,都可以考虑用二分搜索 Leetcode 34 /** * @param {number[]} number * @param {number} target * @return {number[]} */ const binarySearch = (nums, target, lower) => { let left = 0, right = nums.length - 1, ans = nums.length;

2022-04-21 16:48:49 1313

原创 JS3个距离

2022-01-21 16:54:37 295

原创 二倍精灵图的做法

先将精灵图等比例缩放为原来一半 然后测量所需图的坐标 用bg:url n-r 坐标 然后bg-size要将缩放一半后大小写上去

2021-12-01 23:35:07 354

转载 CSS3新特性总结自用

https://segmentfault.com/a/1190000010780991

2021-11-10 10:48:17 117

原创 SCAU 18308 最长公共子序列

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int dp[1001][1001]; char s1[1001],s2[1001]; int main() { cin>>s1>>s2; int len1=strlen(s1),len2=strlen(s2); f

2021-05-19 13:01:25 287

原创 SCAU 8633 回文划分

#include <iostream> #include<cstdio> #include<math.h> #include<cstring> using namespace std; char a[1005]; int dp[1005]; int ok(int i,int j) { for(int k=0;k<=(j-i)/2;k++) if(a[i+k]!=a[j-k]) return 0; return 1; } i

2021-05-19 13:00:41 160

转载 SCAU 1079 三角形

看到一个很简洁的代码,分享一下 转自@Jesses_is_me 思路:这个代码中 i 的含义是三角形中的斜边或是三角形中较长的直角边 ,i是斜边时,通过i^2= b^2+ k^2 && i-b=1 确定上界 当i为较长直角边时,i最小时趋近于b,代入i=b到k^2 = b^2 + i^2 得到i的下界, if语句判断是否为整数 #include <iostream> #include <math.h> #include <stdlib.h> using n

2021-05-13 17:15:45 249

原创 SCAU 18730 涂色问题

ans = 总方案 - 不发疯的方案 要在求幂过程中取模 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; #define mod 1000000007 long long pow(long long x,long long y) { if(y==1) { return x%mod; } long long half=po

2021-05-11 15:25:17 254

原创 SCAU 8615 快乐

01背包 需要提前对i=0即选择第一道题与否进行初始化 #include<iostream> #include<algorithm> #include<cstdio> using namespace std; //定义DP数组的定义为写到i题的快乐值 int dp[100][10000]; int n; int gethappy[1000]; int losspow[10000]; int main() { cin>>n; for(int i=

2021-05-08 14:08:16 215

原创 SCAU 18920 校赛排名2

思路:这道题和前一个校赛排名不一样的地方就是输入的数据,这道题我们要先录入输入的队伍名字,后续通过查找队伍名字录入相关数据 //参考了别的文章的把ac题的题目改成数字的小细节 /*描述 下面是校赛的排名规则: 比赛期间,提交代码后,系统会返回正确或错误等结果。最后的获胜者为正确解答题目最多,如果同题数则总用时最少的队伍。 每道试题的时间花费将从竞赛开始到试题提交并且被判定为正确为止,其间每一次提交运行结果被判错误的话将被加罚20分钟时间, 未正确解答的试题不记时,如果已经返回正确的题目再重复提交则不影响结果

2021-04-28 20:30:28 387

转载 SCAU 18725 宇宙跃迁

这个是搜到的二分做法 顺便附上我的不知道哪里错了的做法 大家有兴趣看着乐呵乐呵就行(大家写题还是按照oj上的标签方法写吧) #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; /*在基地的科学家发明“透镜”之后,宇宙航行变得更加效率。 作为基地元首的的代理人,你需要在K天内乘坐飞船到达首都川陀。 飞船可以花费一天

2021-04-28 17:11:38 453 1

原创 SCAU 18107 校赛排名

#include<malloc.h> #include<iostream> #include<cstdio> #include<cstring> #include <vector> #include<algorithm> #include<math.h> #include<queue> using namespace std; typedef struct { int ac; int time;

2021-04-27 23:12:56 402

原创 SCAU 18935 贪吃的小Q

#include<malloc.h> #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<math.h> #include<queue> using namespace std; int n,m; int sum(int s) { int sum1=0; int i=0; for(i=0;

2021-04-27 13:57:03 240 1

原创 SCAU 18726 查找最接近的元素

虽然知道顺序会超时,但是我还是试了一下-。- #include<malloc.h> #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<math.h> #include<queue> using namespace std; int erfen(int x,int a[],int n) { int lo

2021-04-27 12:54:14 187

原创 SCAU 18722 稀疏矩阵的运算

#include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct node { int a,b,c;//横 纵 数据 }data[25038]; bool paixu(struct node s,struct node d) { if(s.a==d.a) { return s.b<d.b;//x相等按y从小到大 }

2021-04-23 17:07:10 591

原创 18124N皇后

#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; //queen的坐标为(col,a[col]) int a[20],k,answer; //利用递归 void dfs(int col) { if(col==k+1)//最后若递归结束时col+1 使得col=k+1 { a

2021-04-21 20:48:26 200

原创 18959待修改

#include<malloc.h> #include #include #include #include #include<math.h> #include using namespace std; int main() { char tree[10000]; char s[10][10000]; gets(tree); int t=0; int len=strlen(tree); int cengshu=log(len)/log(2)+1; for(int i=1;i<=

2021-04-21 12:54:11 142

转载 18724 二叉树的遍历运算

Description 二叉树的三种遍历都可以通过递归实现。 如果我们知道一棵二叉树的先序和中序序列,可以用递归的方法求后序遍历序列。 输入格式 两行,第一行一个字符串,表示树的先序遍历,第二行一个字符串,表示树的中序遍历。树的结点一律用小写字母表示。 思路: 先序的第一个结点为树的根节点,中序确定了左右子树,然后递归遍历输出结点。 #include<iostream> #include<cstring> using namespace std; char pre[1000]; ch

2021-04-13 13:41:59 474 2

转载 SCAU 18930 逛街

这题的思路是用单调栈,栈里储存的是能看到的楼栋高度。 用两个栈储存当前位置向左看向右看的楼栋,两个栈的大小+1(当前位置的楼)即为答案 附上大佬的简洁代码 #include <iostream> #include <vector> #include <stack> #include <algorithm> using namespace std; vector<int> a, b; stack<int> st1, st2; int

2021-04-11 20:40:02 160

原创 SCAU 18931 分形

#include <iostream> #include <cmath> #include <cstring> using namespace std; char c[1000][1000]; int main(){ int n; c[0][0] = 'X'; for(int len = 1;len <= pow(3,5);len *= 3){ for(int i = 0;i < len;i++){

2021-04-09 21:00:17 406

原创 小易爱回文

#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { string s; cin>>s; int i; int len= s.size(); for(i=0;i<len;i++) { string temp=s; reverse(temp.beg

2021-04-08 13:39:05 270

原创 SCAU 偷懒的士兵2

//分治递归 #include<iostream> #include<algorithm> //就按照视频说的写就好了 #define wrong 123456789 using namespace std; int F(int s,int step,int N) { if(N==3) return wrong; else if(N<3) return s; else return min(F(s,step

2021-04-07 20:20:36 413

原创 SCAU------1142 巡逻的士兵

Description 有N个士兵站成一队列, 现在需要选择几个士兵派去侦察。 为了选择合适的士兵, 多次进行如下操作: 如果队列超过三个士兵, 那么去除掉所有站立位置为奇数的士兵, 或者是去除掉所有站立位置为偶数的士兵。直到不超过三个战士,他们将被送去侦察。现要求统计按这样的方法,总共可能有多少种不同的正好三个士兵去侦察的士兵组合方案。 注: 按上法得到少于三士兵的情况不统计。 1 <= N <= 2的32次方-1 输入格式 有多行(可能有上百行,尽量优化代码),每行一个数字N,最后一行是0

2021-04-06 20:22:45 202

原创 SCAU 18964 蛇形方阵

Description 给出一个不大于 9 的正整数 n,输出 n×n 的蛇形方阵。 从左上角填上 1 开始,顺时针方向依次填入数字。 如同样例所示。注意每个数字有都会占用 3 个字符,前面使用空格补齐。 输入格式 一个整数n。 输出格式 n对应的蛇形方阵。 输入样例 4 输出样例 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 //顺时针方向:右下左上 代码如下 #include<iostream> #include<stdio.h>

2021-04-04 15:51:24 467

原创 SCAU 18942 偏爱字母

Description 小美喜欢字母E,讨厌字母F。在小美生日时,小团送了小美一个仅包含字母E和F的字符串,小美想从中选出一个包含字母E数量与字母F数量之差最大的子串。 *子串:从字符串前面连续删去若干个字符,从后面连续删去若干个字符剩下的字符串(也可以一个都不删),例如abcab是fabcab的子串,而不是abcad的子串。 我们将空串看作所有字符串的子串。 输入格式 第一行一个正整数n表示字符串的长度。 第二行长度为n,且仅包含大写字母’E’,’F’的字符串(不含引号) 输出格式 输出一个整数,表示最大

2021-04-03 16:10:34 559

原创 SCAU 18939 最长单词

#include #include using namespace std; char a[550],b[510],Max[510]; int main(){ gets(a); int len=strlen(a); int k=0,mm=0; for (int i = 0; i < len;i++) { if(a[i]’ '||a[i]’.’){ b[k]=’\0’;//在末尾加上\0 if(mm<k){//k等于长度 strcpy(Max,b); mm=k;//找到最大长度 } k=0;.

2021-04-02 23:04:38 474

原创 SCAU 18712 递归实现组合————DFS

#include<iostream> #include<cstdio> using namespace std; int book[12]; int box[12]; int n,k; void dfs(int step) { if(step==k+1) { for(int i=1;i<=k;i++) { printf("%d ",box[i]); } printf("\n"

2021-04-01 14:43:06 210

原创 SCAU 18928 递归实现全排列(字典序)

//递归回溯 具体思路见下图但是这样输出的并不是字典序,为解决该问题,我在每次交换前加入排序函数,排序交换的位,具体大家可以代数写写。 代码如下 #include <iostream> #include <algorithm> using namespace std; int n; int x[10]; void display(int *x){ for (int i = 0 ; i < n ; i ++) cout<<x[i] ;

2021-04-01 13:27:04 300

原创 SCAU 18718 航行————DFS

DFS #include <iostream> #include <algorithm> #include <cstdio> using namespace std; /*帝国首都为起点(坐标0),基地为终点(坐标L),在这条航线上有N个空间站可以补充飞船的能源。 第i个空间站的坐标为ai,飞船停靠在第i个空间站必须花费bi个银河币,同时让你的飞船能量恢复为最大值M。 出发前飞船的能量是满额的M,每一点能量都可以让飞船航行一个坐标单位。 现在你已经通过募捐(榨篇)获得了

2021-03-31 19:59:49 311

原创 SCAU 18440 走迷宫2 ----------BFS

//BFS //和上个迷宫问题差不多,只是多加了个走出迷宫的条件,用多case而已,多加几个if就好了 //代码如下 #include <iostream> #include<cstdio> #include <algorithm> #include <queue> using namespace std; char a[100][100]; int v[100][100]; int d[4][2]={{1,0},{0,1},{-1,0},{0,-1}}; s

2021-03-31 09:14:26 527

原创 KMP算法个人笔记

计算next函数值 算法4.3中定义了i与j,j指向了前缀末尾,i指向了后缀末尾,起始时,i=1,j=0 在此算法中,next数组的值被定义为最长相等前后缀的值+1 由于字符串首元素储存字符串长度,所以当j=0时,i j同时向前移动,并记录next[0]=0,事实上第一个元素没有前后缀,next值不存在。 当i j指向的对应元素相等时,i j同时向后移,并记录此时next值,而next值计算代码为next[i]=j 实际上如果不先i++ j++的话, j的数值等于最长相等前后缀的值,这里的算法是进行了调整

2021-03-30 14:27:00 113

原创 SCAU 18005 It is not ugly number

//计算丑数的思路:三指针+动态规划 //处理非丑数的思路参考自@weixin_30437337 #include <stdio.h> #include <malloc.h> int least(int x,int y,int z) { int temp = x<y?x:y; return temp<z?temp:z; } int nthUglyNumber(int n){ int nums[n]; nums[0]=1; int p

2021-03-29 12:08:52 698 1

原创 迷宫问题(最短路径)————BFS

迷宫是一个n*m的矩阵,玩家需要迷宫入口(坐标1,1)出发,寻找路径走到出口(n,m)。 请判断玩家能否从迷宫中走出,如果能走出迷宫输出,输出最短的路径长度,否则输出-1。 输入格式 第一行两个整数n和m,代表n行m列。(1<=n,m<=10) 下面n行每行m个字符,0代表可以通行,1代表不可以通行。 输出格式 如果能从迷宫走出,输出最短的路径长度,否则输出-1。 输入样例 8 8 00100010 00100010 00001100 01110000 00010000 01000100 01

2021-03-28 19:32:24 3971

原创 SCAU 18932 出栈序列合法性判定

//思路参考自LEETCODE@acvv_itdef 即下图231 `#include #include using namespace std; stack s; int a[20000],b[20000]; int main() { int n;cin>>n; int flag =0; for(int i=0;i<n;i++) { cin>>a[i]; } for(int i=0;i<n;i++) { cin>>b[i]; } int i=0,j.

2021-03-27 15:20:02 684

原创 SCAU 18933 括号匹配问题

//用while(scanf("%s",s)!=EOF){}过不了 Oj不知道原因 #include <iostream> using namespace std; int main() { string s; while(scanf("%s",s)!=EOF) { int len=s.length(); for(int i=0; i<len; i++) { for(int j=i-1; j>=0; j-

2021-03-26 20:43:00 509 2

原创 SCAU 18938 汉诺塔问题

//不一样的地方就是这道题最终是要移到b上 //解决汉诺塔问题的关键是把最下面的盘子当作一个整体,把剩下的盘子当作另一个整体 //代码如下 #include <stdio.h> #include <string.h> int m=0; void hanoi(int n,char a,char b,char c) { if(n==1) printf("%c->1->%c\n",a,b); else { hanoi(n-1,a,c,

2021-03-26 16:55:09 1918

转载 SCAU 8588 表达式求值

大家可以参考这个大佬 //不过有几点需要更改一下 //根据题目是按空格中止 所以计算结果函数中的while应该以CH==’='为终止条件 //还有就是最后主函数修改一下

2021-03-25 14:54:06 353

原创 8585 栈的应用——进制转换

//只放主函数了 不然审核过不了 #include<stdlib.h> #include<stdio.h> #define OK 1 #define ERROR 0 #define STACK_INIT_SIZE 100 // 存储空间初始分配量 #define STACKINCREMENT 10 // 存储空间分配增量 int main() { SqStack S; InitStack(S); int n; scanf("%d",&amp

2021-03-23 16:59:14 181

原创 SCAU 18925 试卷排序(双向链表)

18925 试卷排序(双向链表) Description 老师要将N张试卷重新排序,每张试卷都有编号为1∼N,采取如下的方法: 先将编号1的试卷放进队列,剩下从第2张到第N张依次放入队列, 放入的时候老师会把编号i的试卷插入到编号为x试卷之前或之后(x<i), 在老师完成这N-1次操作之后,请输出试卷序列的最终编号。 输入格式 第1行为一个正整数N,表示了有N张试卷。 第2-N行,第i行包含两个整数x,p,其中x为小于i的正整数,p为0或者1。 若p为0,则表示将第编号为i的试卷放入编号为x试卷的左边

2021-03-21 10:42:02 649

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除