自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 滑动窗口模板

是:以右指针作为驱动,拖着左指针向前走。右指针每次只移动一步,而左指针在内部 while 循环中每次可能移动多步。右指针是主动前移,探索未知的新区域;左指针是被迫移动,负责寻找满足题意的区间。《挑战程序设计竞赛》这本书中把滑动窗口叫做「虫取法」,我觉得非常生动形象。因为滑动窗口的两个指针移动的过程和虫子爬动的过程非常像:前脚不动,把后脚移动过来;模板中的 sums 需要根据题目意思具体去修改,本题是求和题目因此把sums 定义成整数用于求和;对于本题而言,就是该区间内的 0 的个数 超过了 2。

2023-11-21 15:35:57 78

转载 python中iter函数

当使用一个循环机制需要下一个项时,调用迭代器的next()方法,迭代完后引发一个StopIteration异常。python中的迭代器用起来非常灵巧,不仅可以迭代序列,也可以迭代表现出序列行为的对象,例如字典的键、一个文件的行,等等。版权声明:本文为CSDN博主「快递小可」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。反序迭代工具:reversed()将返回一个反序访问的迭代器。但是迭代器只能向后移动、不能回到开始、再次迭代只能创建另一个新的迭代对象。

2023-04-18 09:33:46 502

转载 python中yield的用法详解

到这里你可能就明白yield和return的关系和区别了,带yield的函数是一个生成器,而不是一个函数了,这个生成器有一个函数就是next函数,next就相当于“下一步”生成哪个数,这一次的next开始的地方是接着上一次的next停止的地方执行的,所以调用next的时候,生成器并不会从foo函数的开始执行,只是接着上一步停止的地方开始,然后遇到yield后,return出要生成的数,此步就结束。2.直到调用next方法,foo函数正式开始执行,先执行foo函数中的print方法,然后进入while循环。

2023-04-17 20:13:47 285

原创 拿到已开发好的Vue前端代码如何在本地运行?

package.json文件中已经记录了项目所用的所有依赖及其版本,所以打开cmd,定位到项目的根目录,运行如下代码即可:2.运行在打开package.json文件,查看“start”值是什么,将其输入到cmd中运行完之后,如果出现图片中的情况,说明运行成功。在本地浏览器中输入cmd给出的链接“http://localhost:8080”即可查看在运行完之后,报错如下出现问题的原因应该是版本不匹配解决办法:先卸载vue-template-compiler,再装匹配的版本(2)Modu

2022-07-02 10:57:08 3562

原创 模板生成系统

一、解法一(90分)一定要注意以下几个函数应该传的参数是什么:1.substr(pos,length);2.erase(pos,length);#include<bits/stdc++.h>using namespace std;const int N = 105;struct node { string name; string value;}a[N];string str[N];int main() { int n,m; cin&

2022-03-10 11:23:46 227

原创 ccf 节日

本次刷题错误:计算某一天是周几的时候,需要将每一天往后移动一天,因为1850/1/1是周二,顾对7取模之前应该先加一#include<bits/stdc++.h>using namespace std;int isRun(int x) { if(x%400==0||(x%4==0&&x%100!=0)) return 1; return 0;}int day[7] = {1,2,3,4,5,6,7};int mon1[12]={31,28,31

2022-03-09 10:46:27 166

原创 ccf 集合竞价

#include<bits/stdc++.h>using namespace std;const int N = 5010;struct node { string t; int flag; int s; double p;}a[N];bool compare(node x,node y) { return x.p<y.p;}int main() { string tt; int n=0; while(

2022-03-09 08:05:43 179

原创 字符串匹配

#include<bits/stdc++.h>using namespace std;const int N = 105;int nextT[N];void getNext(string pattern) { int m = pattern.size(); int i = 0; nextT[0] = -1; int t = nextT[i]; while (i < m) { if (t == -1 || pattern[i] == pattern[t]) {

2022-02-26 21:05:43 115

原创 命令行选项

#include<bits/stdc++.h>using namespace std;const int N = 30;bool o1[N], o2[N]; //o2为有参数选项,o1为无参数选项string ans[N];int main() { string str; cin >> str; for (int i = 0; i < str.size(); i++) { if (i + 1 < str.size() && st

2022-02-26 19:00:15 249

原创 最大的矩形

#include<bits/stdc++.h>using namespace std;const int N = 1010;int h[N];int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &h[i]); } int result = 0; //sort(h+1,h+n+1); for (int i = 1; i <= n;

2022-02-22 15:18:16 505

原创 ISBN号码

#include<bits/stdc++.h>using namespace std;int main() { string str; cin >> str; int a[10]; int pos = 0; for (int i = 0; i < str.size(); i++) { if (isdigit(str[i])) { a[pos++] = str[i] - 48; } } int sum = 0; for (int i = 0;

2022-02-14 18:06:58 232

原创 csp 窗口

#include<bits/stdc++.h>using namespace std;const int N=50;struct node { int x1,y1,x2,y2; int level; int number;}a[N];bool compare (node x,node y) { return x.level>y.level;}int main() { int n,m; scanf("%d%d",&n,&m); for(i

2022-02-14 17:44:45 119

原创 csp 画图

#include<bits/stdc++.h>using namespace std;const int N = 1000;int a[N][N];int main() { int n; scanf("%d", &n); for (int i = 0; i <= 110; i++) { for (int j = 0; j <= 110; j++) { a[i][j] = 0; } } for (int i = 0; i < n;

2022-02-14 16:59:46 118

原创 Z字形扫描

#include<bits/stdc++.h>using namespace std;const int N = 5500;int a[N][N];int visited[N][N];int dx[4] = {0, 1, 1, -1};int dy[4] = {1, -1, 0, 1};int result[260000];int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i+

2022-02-14 16:30:04 330

原创 csp 数字排序

#include<bits/stdc++.h>using namespace std;const int N=1010;struct node { int cunt; int data;}a[N];bool compare(node x,node y) { if(x.cunt!=y.cunt) { return x.cunt>y.cunt; } return x.data<y.data; }int b[N];int main() { in

2022-02-13 22:23:10 177

原创 csp 日期计算

#include<bits/stdc++.h>using namespace std;bool yJudge(int y) { if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { return true; } return false;}int m1[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //闰年int m2[12] = {31, 2

2022-02-13 22:06:27 154

原创 消除类游戏

#include<bits/stdc++.h>using namespace std;const int N = 100;int a[N][N];int b[N][N];//表示(i,j)位置的格子能不能删,能删标记为1,不能删标记为0 int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j+

2022-02-13 21:43:54 1948

原创 俄罗斯方块

#include<bits/stdc++.h>using namespace std;int a[20][20];int b[10][10];int main() { int m; for (int i = 1; i <= 15; i++) { for (int j = 1; j <= 10; j++) { scanf("%d", &a[i][j]); } } int pos = 1; for (int i = 1; i <= 4

2022-02-13 20:52:04 147

原创 csp 火车购票

注意:当没有相连的座位时,从编号较小的座位依次进行分配#include<bits/stdc++.h>using namespace std;const int N=110;int a[N];int chair[25][10];int sum[25][10];int main() { int n,m; scanf("%d",&n); for(int i=1;i<=20;i++) { for(int j=1;j<=5;j++) { cha

2022-02-13 17:53:41 90

原创 csp 工资计算

#include<bits/stdc++.h>using namespace std;int main() { int t; scanf("%d",&t); int s; if(t<=3500) { s=t; } else if(t<=3500+1500-45) { s=(t-105)*100/97; } else if(t<=8000-45-300) { s=(t-455)*10/9; }else if(t<=3500+9000

2022-02-13 15:36:15 345

原创 csp 学生排队

#include<bits/stdc++.h>using namespace std;const int N=1010;int a[N];int main() { int n,m; scanf("%d",&n); scanf("%d",&m); for(int i=1;i<=n;i++) { a[i]=i; } for(int i=0;i<m;i++) { int p,q; scanf("%d%d",&p,&q)

2022-02-13 14:01:01 53

原创 公共钥匙盒

#include<bits/stdc++.h>using namespace std;const int N = 10010;struct node { int id; int type; int time;} a[N];int q[N];bool compare(node x, node y) { if (x.time != y.time) return x.time < y.time; if (x.type != y.type) return x.t

2022-02-13 11:44:45 54

原创 csp 报数游戏

#include<bits/stdc++.h>using namespace std;const int N = 1010;struct node { int pos; int flag;} a[N];int main() { int n, k; int sum = 0; int cunt = 0; scanf("%d%d", &n, &k); for (int i = 1; i <= n; i++) { a[i].pos = i; a

2022-02-12 09:43:40 2576

原创 碰撞的小球

#include<bits/stdc++.h>using namespace std;const int N = 110;struct node { int pos; int v;}a[N];int main() { int n,l,t; scanf("%d%d%d",&n,&l,&t); for(int i=0;i<n;i++) { scanf("%d",&a[i].pos); a[i].v=1; } while(t

2022-02-11 22:58:41 167

原创 csp 买菜

易错点:在双重循环遍历的时候,可能存在以下情况,所以不能找到时间存在交叉的就停止遍历,还需继续往下寻找#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 5010;struct node { int s; int e;}h[MAXSIZE],w[MAXSIZE];int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++)

2022-02-11 20:10:17 103

原创 csp 小明放学

注意:红绿灯凉的顺序:红灯亮完是绿灯,然后是黄灯,以此循环#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 1e5 + 10;struct node { long long k; long long t;} a[MAXSIZE];int main() { int n; long long r, y, g; long long sum = 0; scanf("%lld%lld%lld", &

2022-02-11 19:35:25 294

原创 csp 二十四点

#include<bits/stdc++.h>using namespace std;int priority(char c) { if (c == '#') return 0; else if (c == '$') return 1; else if (c == '+' || c == '-') return 2; else return 3;}int calculate(int x, int y, char c) { if (c == '+') { return

2022-02-11 10:45:04 261

原创 小明种苹果(续)

#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 1010;struct node { int m; int a[MAXSIZE];} tree[MAXSIZE];int ee[MAXSIZE];int main() { int n; int t = 0, d = 0, e = 0; memset(ee, 0, sizeof(ee)); scanf("%d", &n); for

2022-02-10 21:52:48 54

原创 回收站选址

#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 1010;struct node{ int x; int y;}a[MAXSIZE];int dx[8]={-1,-1,-1,0,1,1,1,0};int dy[8]={-1,0,1,1,1,0,-1,-1};int sum[8];int grade[5];int main() { int n; scanf("%d",&n);

2022-02-10 19:13:54 51

原创 csp 稀疏向量

#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 5e5+10;struct node { int index; int value;}u[MAXSIZE],v[MAXSIZE];int main() { int n,a,b; scanf("%d%d%d",&n,&a,&b); for(int i=0;i<a;i++) { scanf("%d%d",&

2022-02-10 15:25:55 180

原创 风险人群筛查

#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 1e3 + 10;struct node { int x; int y;} a[30][MAXSIZE];int main() { int n, k, t, x1, y1, x2, y2; int cunt = 0, sum1 = 0, sum2 = 0; scanf("%d%d%d%d%d%d%d", &n, &k, &

2022-02-10 10:59:17 459

原创 csp 202012-2期末预测之阈值

思路:前缀和#include<bits/stdc++.h>using namespace std;const int MAXSIZE = 1e5+10;struct node { int y; int result;}a[MAXSIZE];bool compare(node xx,node yy) { return xx.y<yy.y;}int sum[MAXSIZE];//前缀和 int main() { int m; scanf("%d",&am

2022-02-09 22:44:12 181

原创 ccf-csp 202104-2 邻域均值

本题可以采用差分的方法做,使用数组b[i][j]记录从a[1][1]一直到a[i][j]的和,然后使用双重循环遍历每个(i,j)点,计算出该点的邻域范围有多大右下角为(x2,y2),左上角为(x1,y1),则(i,j)邻域内的所有元素之和就是b[x2][y2] - b[x1][y2] - b[x2][y1] + b[x1][y1]但是,要注意边界情况中(x2,y2)和(x1,y1)的取值#include<bits/stdc++.h>using namespace std;int.

2022-02-06 11:08:49 530

原创 前缀和与差分

一、HJ浇花题目链接:https://ac.nowcoder.com/acm/contest/322/M代码:#include<bits/stdc++.h>using namespace std;const int maxsize1 = 1e6+10;const int maxsize2 = 2e5+10;int a[maxsize1];int cant[maxsize2];//cant[i]表示被浇了i次水的花有多少盆 int main() { int n; s

2022-02-04 22:00:20 739

原创 最长递增子序列的优化——时间复杂度为O(nlogn)

//最长递增子序列的优化——时间复杂度为O(nlogn)#include<stdio.h>#include<iostream>#include<string>using namespace std;const int MAXN = 1000+10;const int INF = INT_MAX;int support[MAXN];int arr[MAXN];int main() { int n; support[0] = -INF; for

2022-01-28 16:11:29 533

原创 throw new Error(“Cannot parse config file: ‘“ + fullFilename + “‘: “ + e3)

在用node.js的第三方模块——config时,报错如下:解决方法:我的config文件夹下有default.json、production.json、development.json、custom-environment-variables.json四个文件,报如上错误,很可能是因为default.jaon、custom-environment-variables.json是一个空文件,如果当前是development环境,development.json文件中必须有内容;同理,如果是produc

2020-10-06 09:32:49 1177 2

原创 Error: data and hash arguments required

报错如下:

2020-09-30 21:14:29 844 1

原创 _http_server.js:241 throw new ERR_HTTP_INVALID_STATUS_CODE(originalStatusCode);

_http_server.js:241throw new ERR_HTTP_INVALID_STATUS_CODE(originalStatusCode);

2020-09-29 18:30:43 1354 2

原创 TypeError: Joi.validate is not a function

在使用joi验证的时候,报错如下TypeError: Joi.validate is not a function经过一番折腾,最后发现应该是因为版本的问题,我下载的版本是13.1.0(但是下载的版本与joi官网的示例是对应的,搞不懂为什么是版本出现问题,希望路过的大佬指点一下)解决办法:先卸载之前的版本npm uninstall joi重新下载正确的版本npm install [email protected]...

2020-09-26 22:09:26 283

原创 hexo+next添加雪花飘落背景效果

该文章以hexo+next为例,介绍添加雪花飘落背景效果步骤(hexo下的其它的主题大同小异)效果请查看我的个人博客在\blog\themes\next\source\js目录下新建snow2.js文件,添加如下代码/*样式一*/(function ($) { $.fn.snow = function (options) { var $flake = $('<div id="snowbox" />').css({ 'positi

2020-09-25 16:14:09 1434

空空如也

空空如也

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

TA关注的人

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