- 博客(23)
- 收藏
- 关注
原创 堆的操作。
堆的操作:1.插入一个数heap[++size]=x,up(size);在最后一个位置插入,在上移动找到合适位置2.求集合当中最小值heap[1]3.删除最小值heap[1]=heap[size];size--;down(1);把第一个点用最大值覆盖再把最大值移动到合适位置4.删除任意一个元素heap[k]=heap[size];size--;down(k),up(k);//二选一5.修改任意一个元素heap[k]=x;down(k),up(k);结构:完全二叉树每一个节点的值都小于左右儿子的
2022-05-25 15:11:02
282
原创 图论之关键路径
//拓扑排序(有向图且领接表)int topsort(struct graphh *gg){ int ss[N*2],top=-1;//栈 int k=0;//表示输出的元素个数 int flag[N];//判断是否访问过该元素 memset(flag,false,sizeof flag); for(int i=0;i<gg->n;i++) if(gg->rr[i]==0&&!flag[i...
2022-05-04 14:25:33
407
原创 树状数组+线段树
树状数组实际应用单点修改 + 区间和询问//树状数组 (前缀和、区间、点更新) const int N=10005;int n,a[N],b[N];//树状数组b int lowbit(int i){ return (-i)&i;}void add(int i,int z)//点更新,a[i]+z { for(i<=n;i+=lowbit(i))//更新所有后继 { b[i]+=z; }}int sum(int i)//前缀和 ,a[1].
2022-04-25 20:30:00
137
原创 Code For 1(一)分而治之
Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and take the deceased Aemon's place as
2022-03-21 15:13:03
399
原创 迷宫问题(Bfs)
迷宫问题 | JXNUOJ定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。输入:一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。输出:左上角到右下角的最短路径,格式如
2022-03-13 20:10:46
150
翻译 Charm Bracelet1.28
OpenJudge - 7113:Charm Bracelet描述Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from theN(1 ≤N≤ 3,402) available charms. Each charmiin the supplied list has a we...
2022-01-28 22:22:05
148
翻译 Maximum Sum Not Exceeding K1.27
OpenJudge - 16:Maximum Sum Not Exceeding K描述find two different numbers from them such that the sum of the two numbers is maximum but not exceeding K.输入First line: two positive integers N (N <= 1000) and K (K <= 1000000).Second line: N positi
2022-01-28 22:05:14
160
翻译 Duplicate Number1,26
描述Given a sequence of N numbers, find a number A that the count of A in the sequence is at least two.输入First line: one positive integer N (N <= 1000).Second line: N positive integers (<= 1000000).输出One integer A.样例输入82 4 2 1 5 3 9 ..
2022-01-28 21:53:28
149
翻译 Zoos‘s Animal Codes 1.25
Zoos's Animal Codes | JXNUOJ描述:The speed of mail sorting is also known as postal code, or post code. Postal area code system has become one of the standards to measure the level of communication technology and postal service in a country.The post cod
2022-01-28 21:40:53
136
翻译 Teamwork1.24
Teamwork | JXNUOJ描述:There are N candidates. Each candidate has a cooperation value and a working value. Select a subset of candidates to form a team, such that the sum of cooperation values is positive and the sum of working values is maximum.输入:Fi
2022-01-28 20:33:19
111
翻译 Maximum sum1.23
OpenJudge - 1481:Maximum sum描述Given a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below: t1 t2 d(A) = max{ ∑ai + ∑aj | 1 <= s1 <= t1 < s2 <= t2 <= n }
2022-01-23 21:32:47
156
翻译 Post Office 1.22
Post Office | JXNUOJ描述:There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer coordinate. There are no two villages in the sam
2022-01-22 08:55:18
137
翻译 Multiple of 3 Or 5
1.20描述:How many positive integers are there which is less than N and is a multiple of 3 or a multiple of 5.输入:One positive integer N (N <= 100000).输出:One integer.样例输入:100样例输出:46描述有多少个小于n的正整数是3或5的倍数输入一个正整数n输出一个数...
2022-01-20 09:42:42
335
翻译 Sum is K
描述:Given a sequence of N numbers. Find different numbers A and B in the sequence so that the sum of A and B equals to K.输入:First line: two positive integers N (N <= 1000) and K (K <= 1000000).Second line: N positive integers (<= 1000000).
2022-01-20 09:26:04
66
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人