自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Matlab制作GUI

GUI 图形用户界面

2022-10-10 16:56:03 4844 2

原创 Matlab小结7(非线性规划)

非线性规划标准型用Matlab求解上述问题,基本步骤分三步:(1) 首先建立M文件 fun.m, 定义目标函数 F(x):function f = fun(x);f = F(x);(2) 若约束条件中有非线性约束: c(x) 或 ceq(x)=0,则建立 M文件nonlcon.m定义函数c(x)与ceq(x): function [c,ceq]=nonlcon(x)c =…ceq=…(3) 建立主程序, 非线性规划求解的函数fmincon,命令的基本格式如下:[x,fval]=fminco

2021-07-29 21:39:15 1822

原创 Matlab小结6(线性规划)

[x,fval] = linprog(f,A,b)[x,fval] = linprog(f,A,b,Aeq,beq)[x,fval] = linprog(f,A,b,Aeq,beq,lb,ub)x 返回的是决策向量的取值; fval 返回的是目标函数的最优值; f 为价值向量; A,b 对应的是线性不等式约束; Aeq,beq对应的是线性等式约束; lb 对应的是决策向量的下界; ub 对应的是决策向量的上界.Linprog中无约束则用[]代替,ub无可省略,也可写ub=[inf;inf;inf].

2021-07-29 21:28:58 1533 1

原创 Matlab小结5(图论)

G = graph(s,t,weights) ——使用节点对组s,t和权重向量weights创建赋权无向图G = graph(s,t,weights,nodes)——使用字符向量元胞数组nodes指定节点名称G = graph(s,t,weights,num) ——使用数值标量num指定图中的节点数G = graph(A[,nodes],type)——仅使用A的上或下三角形阵构造赋权图,type可以是’upper’ 或‘lower’sparse邻接矩阵转系数矩阵例1无权无向图clc,

2021-06-21 20:44:43 2862 1

原创 Matlab小结4(极限)

L=limit(f,x,x0,’left’or’right’)若仅趋于x0,则’left’or’right’可省略;x可省略,省略默认为x;xo也可省略,省略后默认0,无穷用inf表示(不需要单引号)极限不存在时输出NaN意为Not a Number区间极限feval例syms a b positive,syms x;f=a*sin(8*x^2)+b*cos(-2*x+2);L=feval(symengine,'limit',f,'x=infinity','Intervals')括号内全.

2021-06-21 20:32:33 384

原创 Matlab小结3(绘图)

plot(x,y,’颜色’) –b蓝色,-r红色subplot(n,m,k)其中n行数m列数k区域序号,例如y=@(x)sin(tan(x))-tan(sin(x));x1=[-pi:0.05:pi];x2=[-pi:0.0001:pi];y1=y(x1);y2=y(x2);subplot(1,2,1),plot(x1,y1,'-b')subplot(1,2,2),plot(x2,y2,'-r')subplot的前两个数字1、2意为把结果窗口分割为一行两列,放两张图,编号1、2即括号内

2021-06-02 13:14:00 381

原创 Matlab小结2(函数)

代码最后一句不能加分号 ; 不然不出结果simplify函数:化简,例一z= (x^2y + yx - x^2 -2x)/(x2*(x3-x(x+1)(x-1))y);simplify(z)输出结果-(x - y - xy + 2)/(x2*y);例二f=x+x2+2x+5x^2;simplify(f)输出3x*(2*x + 1)collect函数合并同类项,同上例一collect(z)结果((y - 1)x + y - 2)/(yx^2),例二collect(f)结果是 6x^2 + 3xnum

2021-05-30 22:09:22 847

原创 Matlab小结1(矩阵)

MATLAB语言的变量名规则:由一个字母引导,后面可以为其他字符;区分大小写 Abc ≠ ABc ≠ abC , etc.有效的变量名 MYvar12, mY_Var12 和 MyVar12_错误的变量名 12MyVar, _MyVar12, MyVar-%注释数据结构:① 数值型数据结构双精度数值变量64位 (8字节),double() 函数将数组转换为双精度单精度数据结构 single(),32位(4字节)uint8()常用于图像表示和 处理,8位int8(),int16(),in

2021-05-10 22:51:00 855

原创 Codeforces Round #664

A - Boboniu Likes to Color Balls#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;int a[5];int main(){ int t; cin>>t; while(t--) { int ji=0,ou=0,minn=INF,f=0; for(int i=1;i<=4;i++) {

2020-08-13 17:36:58 92

原创 Codeforces Round #663

A.Suborraysor运算:两个二进制数,每个位置如果都为0,取0,否则取1输出一个序列使得任意连续个数连续做or运算,值大于等于连续的数的数量代码就是输出1到n ,因为我看通过的人特别多所以直接猜的,猜的依据是两个数做or运算得到的数一定大于等于 两个数中大的那一个(好像是相等时取等),并且这个数肯定远大于长度( j - i + 1 ),因此按顺序输出符合题意。C. Cyclic Permutations由1~n组成的排列,使得对于某一个数,前后都有大于它的数,称为环,求至少有一个环的排列

2020-08-12 16:44:08 85

原创 Codeforces Round #662

B. Applejack and Storages给出一堆长度的线段,每次增加或减少某个长度的,问能否构成一个正方形加一个矩形#include<bits/stdc++.h>using namespace std;int a[100010],s2=0,s4=0;void add(int x){ a[x]++; if(a[x]==2) s2++; else if(a[x]==4) s2--,s4++; else if(a[x]==6) s2++;

2020-08-09 22:18:08 91

原创 7.30日结

修改中含有加和乘的线段树传送门#include <bits/stdc++.h>#define MAXN 100010#define ll long longusing namespace std;int n, m, mod;int a[MAXN];struct node{ ll sum, add, mul; int l, r;}s[MAXN*4];void pushdown(int pos) { s[pos << 1].sum = (s[pos <&l

2020-07-31 23:23:04 108

原创 7.29日结

P1637 三元上升子序列题目#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;int n,m,t1[30010],t2[30010],a[30010],b[30010],l[30010],r[30010];inline int lowbit(int x){ return x&(-x);}inline int pos(int x){ return lower_bound(b+1

2020-07-30 00:41:00 142 1

原创 7.28日结

昨天对树状数组的理解好像有点问题,今天又重新理解了一下,首先是这三个最基本的代码int lowbit(int x){ return x&(-x);}void add(int x,int k){ for(;x<=n;x+=lowbit(x)) t[x]+=k;}int ask(int x){ int ans=0; for(;x;x-=lowbit(x)) ans+=t[x]; return ans;}场景1:

2020-07-28 22:03:31 123

原创 7.27日结

个人对lowbit() 的理解,int lowbit(x){return x&(-x);}n 补码是 ~ n ,~n+1=-n,所以写x&(-x)而不是x&(-x+1)两个应用:首先是查询,g以上图的 节点6 为例(图源b站),6-lowbit(6)=4,4-lowbit(4)=0,t [ 6 ] 表示的是 a [ 5 ] ~ a [ 6 ] 的和,t [ 4 ] 表示的是 a [ 1 ] ~ a [ 4 ] 的和,因此t [ 6 ] + t [ 4 ] 得到是 a [.

2020-07-27 21:23:49 102

原创 Codeforces Round #659

A给出 n 个数,要求第 i 个数与第 i+1 个数与 ai 个相同#include <iostream>#include<vector>#include<algorithm>#include<string.h>using namespace std;string a, b, c;int Maps[1005],maxsize = 0;void cmpt(string &a, string &b,int size){

2020-07-25 20:53:12 99

原创 7.24补题

CodeForces - 1213C给出n,m,求小于等于 m 的范围内所有 n 的倍数的最后一位的和#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;int a[11];int main(){ int t; cin>>t; while(t--) { long long n,m,x; cin>>n>>m; x=m; x=

2020-07-25 20:32:16 84

原创 7.23补题

CodeForces - 1216C无穷大的第一象限有三个长方形,给出分别的左下右上两顶点的坐标,第一个白的先放,后放两黑,问白还能不能看到#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;int main(){ long long x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6; cin>>x1>>y1>>x2>>y2

2020-07-23 20:00:13 80

原创 Codeforces round #658

C1给出一串01字符,每次操作选中前 i 个,0和1互换且整体倒过来,问经过几次并且选择前几个可以得到目标字符串#include<bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { int n; cin >> n; string str1; string str2; cin

2020-07-22 23:25:03 107

原创 7.21补题

CodeForces 1234B1有n条消息,类似QQ的聊天框,每收到一个当前聊天框里没有的联系人的消息就加入聊天框,但一个聊天框只能最多只能有k个不同的联系人,不同的是,每收到一条聊天框里已有联系人的消息,该联系人不需要置顶,聊天框顺序不变,如果聊天框已满,则删除最先加入的那个,求收完所有消息时聊天框里有几个联系人即他们的顺序#include<bits/stdc++.h>using namespace std;vector<int> h;int n,m;int main

2020-07-22 21:21:19 133

原创 7.20补题

CodeForces - 1238A给出x,y(x>y),问x-y是否可以用一个素数的k(k>0)倍表示#include <bits/stdc++.h>using namespace std;int main(){ int t; cin >> t; while(t--) { long long x,y,z; cin>>x>>y; z=x-y; if(z<=1) cout<<"NO"<&l

2020-07-20 23:15:26 77

原创 Codeforces Round #657

A给出一串长 n 的字符,?可以随便改变,问能否变成abacaba只出现一次的字符串,如果能还要输出字符串#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;string ss = "abacaba";int main(){ int t; cin >> t; while(t--) { int n; cin >> n; string s; cin

2020-07-19 23:55:06 74

原创 Codeforces Round #656

C给出 n 个数,求最少去掉前几个可以满足以下三个之一,1一段不严格增加一段不严格减,2一段不严格增,3一段不严格减#include<bits/stdc++.h>#define INF 0x3f3f3f3f#define m 2008using namespace std;int a[200010];int main(){ int t; cin>>t; while(t--) { int n; cin&gt

2020-07-18 23:40:10 65

原创 7.16补题

CodeForces - 1257E *给出三组数长度分别为k1,k2,k3,每次可以移动一个数到另一个组,问最少需要几次可以让三个组的分别排序后按k1,k2,k3的顺序正好是1到(k1+k2+k3)的顺序#include<bits/stdc++.h>#define INF 0x3f3f3f3fusing namespace std;long long dp[200010][4];int a[200010];int main(){ int n,k1,k2,k3,m;

2020-07-17 18:00:06 115

原创 7.15补题

CodeForces - 1249B2n个人,每个人在一天结束交给ai,问最少几天可以回到自己手里#include<bits/stdc++.h>using namespace std;int t,n;int a[220000],b[220000];int main(){ cin>>t; while(t--) { cin>>n; memset(b,0,sizeof(b)); for(int

2020-07-16 00:02:59 81

原创 7.14补题

Codeforces1260D给出m个士兵,每个士兵有迅捷值ai,士兵可以通过危险值不大于他的陷阱,给出k个陷阱,每个陷阱有位置l,失效的位置r和危险值d,给出t秒从0走到n+1,求最多带几个士兵过去#include <bits/stdc++.h>using namespace std;const int maxn=201000;int m,n,k,t;int ai[maxn];struct node{ int li,ri,wi;};node sum[maxn];bo

2020-07-14 23:20:07 123

原创 7.11补题

CodeForces - 1249B2每个数都有一个对应的数字p,每一天第i个人的书给pi,求书回到自己手上需要的天数。#include<bits/stdc++.h>#define N 200010using namespace std;int kds[N];bool vis[N];map<int,int> mp;vector<vector<int>> v;vector<int> vv;void dfs(int index){

2020-07-11 23:05:28 81

原创 7.10补题

CodeForces 1251A一串字符,如果一个字母只有连续出现偶数次,则键盘上这个字母的键是坏的,输出键位没坏的字母(只算出现的字母)#include <iostream>#include <cstdio>#include <cmath>#include <string>#include <cstring>#include <algorithm>#include <iomanip>#define INF

2020-07-11 00:00:02 131

原创 7.9补题

CodeForces-1257C一个数组有出现次数的最多的数,且这个数唯一,则该数组处于被支配状态,问它的连续的子段是否可以处于被支配状态,说人话就是找出一个子段,使得该子段出现两个相同的数字且最短,#include <iostream>#include <cstdio>#include <cmath>#include <string>#include <cstring>#include <algorithm>#incl

2020-07-10 00:49:17 90

原创 7.8补题

CodeForces 1256C给出m块的木板长,要求必须每块都用,并且按顺序铺在河面上,每次可以向前跳1到d格,跳到的地方必须有木板或是终点,问能否从0跳到n+1,图是别人的

2020-07-08 23:35:29 78

原创 7.7补题

CodeForces - 1260B题意:给出两个数,可进行多次操作,每次操作选中一个正数x,一个数减去x,另一个减去2*x,问经过多次操作是否可以将两个数同时变为0.#include <iostream>#include <cstdio>#include <cmath>#include <string>#include <cstring>#include <algorithm>#include <iomanip&

2020-07-07 23:46:45 85

原创 7.6补题

CodeForces - 1272B题意:起始位置原点,UDLR分别代表上下左右移动,要求最后回到原点并且不能有点经过两次,根据给出的步骤判断是否符合要求,符合可删去部分输出重拍后的走法#include <iostream>#include <cstdio>#include <cmath>#include <string>#include <cstring>#include <algorithm>#include &lt

2020-07-06 23:59:44 818

原创 CF977D

Polycarp likes to play with numbers. He takes some integer number xx, writes it down on the board, and then performs with it n−1n−1operations of the two kinds: divide the number xxby 33(xxmust be divisible by 33); multiply the number xxby 22. Aft

2020-06-07 22:36:16 146

原创 近期CF

Codeforces Round #638 (Div. 2)B. Phoenix and BeautyPhoenix loves beautiful arrays. An array is beautiful if all its subarrays of length k have the same sum. A subarray of an array is any sequence of consecutive elements.Phoenix currently has an array a

2020-05-17 23:04:12 76

原创 CODEFORCES近期总结

Codeforces Round #636 (Div. 3)A. CandiesRecently Vova found nn candy wrappers. He remembers that he bought xx candies during the first day, 2x2x candies during the second day, 4x4x candies during th...

2020-04-29 20:41:16 216

原创 DP第九周

1.一个在不能使用万能头文件的网站可能会出现的错误\temp\21607497.34484\Main.cpp(11) : error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no aceptable convers...

2020-04-26 22:06:22 136

原创 DP总结

这周关于格式的方面的收获就是ios::sync_with_stdio(0);cin.tie(0);可以节省cin的时间,让他和scanf一样其余的收获主要还是关于思维方面,1.有关求最大子段和的问题,如果一个字段和小于0,按理说应该将和置为0,再加下一个数,但关键在于如何表达,如果计算和之后与0比较,会导致全是负数的最大子段和为0,所以正确的应该是先比较前一个与0的大小,然后再决定加还是...

2020-04-05 23:20:35 84

原创 FatMouse's Speed

FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence...

2020-04-02 18:13:17 93

原创 动态规划

个人感觉DP的关键在于对现状态的表述和状态转移方程的表达,做题步骤可以分为以下几步1.将所求的目标数组看作一个集合,用已知条件描述2.求集合最值3.对集合进行划分,看子情况4.最后代入代码以下面两题为例(一复制页面就崩掉,所以不打题目了)合并石子1首先对集合DP[ i ][ j ]进行描述:将 i~j 合并为一堆所需要的最小代价2极值属性为min3对集合进行划分,从 i 到 j-...

2020-03-29 23:59:33 60

原创 DP A

Given a set of n integers: A={a1, a2,…, an}, we define a function d(A) as below: Your task is to calculate d(A). Input The input consists of T(<=30) test cases. The number of test cases ...

2020-03-24 08:22:58 185

空空如也

空空如也

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

TA关注的人

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