Miracle_QSH的博客

私信 关注
Miracle_QSH
码龄3年
  • 27,971
    被访问量
  • 118
    原创文章
  • 81,653
    作者排名
  • 53
    粉丝数量
  • 于 2018-08-06 加入CSDN
获得成就
  • 获得25次点赞
  • 内容获得12次评论
  • 获得29次收藏
荣誉勋章
TA的专栏
  • 顺序表
    7篇
  • 链表
    11篇
  • 栈与队列
    11篇
  • 串、数组、广义表
    4篇
  • 二叉树
    7篇
  • 图论
    3篇
  • 查找
  • 并查集
    1篇
  • 哈希
  • 线段树
    1篇
  • DFS
    1篇
  • 最小生成树
    1篇
  • 二分匹配
    1篇
  • 二分答案
    1篇
  • JAVA
    18篇
  • 博弈
    3篇
  • 容斥
    4篇
  • DP
    9篇
  • 思维
    4篇
  • 数位DP
    5篇
  • 网络流
    1篇
  • 线段树点修改
    2篇
  • 线段树区间修改
    1篇
  • 英语
  • JAVA多线程
    1篇
  • 其他
  • 树的直径
    3篇
  • 树形DP
  • 学习笔记
    6篇
  • 树状数组
    1篇
  • 寒假集训_动态规划
    1篇
  • AC自动机
    1篇
  • 最近
  • 文章
  • 资源
  • 问答
  • 课程
  • 帖子
  • 收藏
  • 关注/订阅

换新博客啦!!!

新博客地址:miracle-qsh.github.io
原创
157阅读
0评论
2点赞
发布博客于 2 年前

P3808 【模板】AC自动机(简单版)

#include<bits/stdc++.h>using namespace std;queue<int> q;const int N = 500010;struct AC_automaton{ int c[N][26], val[N], fail[N], cnt; //c数组记录字典树节点,val数组为该节点是否为字符串结尾(个数)(记录字符串...
原创
136阅读
0评论
1点赞
发布博客于 2 年前

P2051 [AHOI2009]中国象棋(动态规划&&分类讨论)

洛谷题解:https://www.luogu.org/problemnew/solution/P2051#include <bits/stdc++.h>using namespace std;typedef long long ll;const ll MAXN = 105;const ll MOD = 9999973;ll dp[MAXN][MAXN][MAXN];...
原创
130阅读
0评论
1点赞
发布博客于 2 年前

树状数组 做题笔记1

HDU - 1166 敌兵布阵:#include <bits/stdc++.h>using namespace std;int a[50005];char cmd[1005];int main(){ int t, n, m, i, j, k, ca = 1; scanf("%d", &t); while(t--) { ...
原创
90阅读
0评论
1点赞
发布博客于 3 年前

树的直径 学习笔记2(思维)

CodeForces - 1085D - Minimum Diameter Tree:题目大意:给你一棵树,让你分配边权,使树的直径最小。解题思路:均分给叶子节点,其余边权为零,这样答案一定是最小的。#include <bits/stdc++.h>using namespace std;int du[100005] = {0};int main(){ in...
原创
114阅读
0评论
0点赞
发布博客于 3 年前

JAVA中的线程 学习笔记

概念:1、JAVA多线程机制:不同线程之间的快速切换2、程序:静态代码3、进程:一次程序的动态执行过程4、线程:比进程更小的执行单位5、线程对象:用Thread及其子类表示多线程:public class Main { public static void main(String[] args) { // TODO Auto-generated method ...
原创
212阅读
0评论
0点赞
发布博客于 3 年前

树形DP 学习笔记1(树的最长路径)

POJ - 2631 Roads in the North:题目大意:给你一棵树,求树的最长路径,也就是树的直径。树的直径必然是树上某一个点开始往下的最长链和次长链之和,因此,对于每个节点记录两个值 dp1[ i ] 表示以 i 为根的子树中,i 到叶子节点的距离最大值,dp2[ i ] 表示以 i 为根的子树中, 除距离最大值所在的子树,i 到叶子节点的距离最大值(次大值):d...
原创
659阅读
0评论
0点赞
发布博客于 3 年前

树的直径 学习笔记1(入门)

 POJ - 2631 Roads in the North:题目大意:给你一棵树,求这棵树的直径。树的直径:树中最长的简单路径。简单路径:路径上各点均不重复。以下证明内容转自https://www.cnblogs.com/a-clown/p/6131346.html这里给出树的直径的证明:  主要是利用了反证法:  假设 s-t这条路径为树的直径,或者称为树上的最长路...
原创
134阅读
0评论
0点赞
发布博客于 3 年前

结构体中的运算符重载

struct node{ int data; bool operator < (const node b)const { return data < b.data; }}; 
原创
1642阅读
1评论
1点赞
发布博客于 3 年前

CodeForces - 1085D - Minimum Diameter Tree(思维)

题目大意:给你一棵树,让你分配边权,使树的直径最小。解题思路:均分给叶子节点,其余边权为零。#include <bits/stdc++.h>using namespace std;int du[100005] = {0};int main(){ int n, m, i, j, k; scanf("%d %d", &n, &m); ...
原创
165阅读
0评论
0点赞
发布博客于 3 年前

CodeForces - 1085C Connect Three(思维)

题目链接:https://cn.vjudge.net/problem/CodeForces-1085C题目大意:给了你三个点,让你建一条路把三个点都连起来,路径尽可能小。解题思路:构造题,找到中间位置的点,以他做垂线,两边的点水平连接。#include <bits/stdc++.h>using namespace std;set <pair<int, in...
原创
143阅读
0评论
0点赞
发布博客于 3 年前

数位DP 学习笔记2

题目HDU 4734 F(x):题目大意是给你两个数A,B,定义F(A)= 每个数位的数 * 2 ^ (位数 - 1)。求 0 - B 区间里的 F(x) <= F(A) 的数字的个数。一个数位DP的做法(TLE):#include <bits/stdc++.h>using namespace std;typedef long long ll;ll a[100...
原创
113阅读
0评论
0点赞
发布博客于 3 年前

数位DP 学习笔记1(数位DP入门)

HDU 2089 不要62:题目大意是给你一个区间,让你统计这个区间里不包含 4 和 62 的数字的个数。最朴素的思路是:对于每个区间 [l, r],遍历所有在区间 [l, r] 里的数字,然后检查每个数字是不是合法(没有 4 和 62 ),如果合法答案加一。代码如下:#include<bits/stdc++.h>using namespace std;boo...
原创
638阅读
1评论
1点赞
发布博客于 3 年前

HDU - 2841 Visible Trees (容斥原理)

#include<bits/stdc++.h>using namespace std;typedef long long ll;ll prim[100005], lenp = 0, isprim[100005] = {0};ll data[100005], lend;ll n, m, t, ans;void getprim(){ ll i, j, k; ...
原创
77阅读
0评论
0点赞
发布博客于 3 年前

HDU - 2841 Visible Trees (容斥原理)

#include<bits/stdc++.h>using namespace std;typedef long long ll;ll prim[100005], lenp = 0, isprim[100005] = {0};ll data[100005], lend;ll n, m, t, ans;void getprim(){ ll i, j, k; ...
原创
77阅读
0评论
0点赞
发布博客于 3 年前

HDU - 1796 How many integers can you find (容斥原理)

#include<bits/stdc++.h>using namespace std;typedef long long ll;ll n, m, a[15], ans, p;ll lcm(ll a, ll b){return a * b / __gcd(a, b);}void dfs(ll x, ll sum, ll num){ if(num > m)ret...
原创
82阅读
0评论
0点赞
发布博客于 3 年前

HDU - 2204 Eddy's爱好 (容斥原理)

#include<bits/stdc++.h>using namespace std;typedef long long ll;ll prim[20] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61};int main(){ ll n, i, j, k, ans; while(scanf("%lld"...
原创
103阅读
0评论
0点赞
发布博客于 3 年前

HDU - 4734 F(x) (数位DP)

#include <bits/stdc++.h>using namespace std;typedef long long ll;ll a[15];ll dp[15][200005];ll po[15], maxx;ll F(ll x){ ll pos = 0, ans = 0, num, pi = 1; while(x) { n...
原创
80阅读
0评论
0点赞
发布博客于 3 年前

ACM英语单词

decimal 十进制binary 二进制 
原创
296阅读
0评论
0点赞
发布博客于 3 年前

HDU - 3555 Bomb(数位DP)

#include <bits/stdc++.h>using namespace std;typedef long long ll;ll a[1005], dp[1005][2][10] = {0};ll cnt(ll po, ll lim, ll la){ if(po == -1)return 1; if(dp[po][lim][la])return dp[...
原创
72阅读
0评论
0点赞
发布博客于 3 年前

HDU - 1698 Just a Hook (线段树区间修改+lazy标记)

#include <bits/stdc++.h>using namespace std;typedef long long ll;struct node{ ll l, r, sum;}a[400005];ll lazy[400005];ll num[100005];void build(ll loc, ll l, ll r){ if(l == r)...
原创
106阅读
0评论
0点赞
发布博客于 3 年前

HDU - 1754 I Hate It (线段树点修改)

#include <bits/stdc++.h>using namespace std;typedef long long ll;struct node{ ll l, r, sum;}a[1000005];ll num[200005];void build(ll loc, ll l, ll r){ if(l == r) { a[...
原创
95阅读
1评论
0点赞
发布博客于 3 年前

HDU - 1166 敌兵布阵(线段树点修改)

#include <cstring>#include <cstdlib>#include <cstdio>#include <algorithm>using namespace std;typedef long long ll;ll num[50005];char cmd[105];struct node{ ll l, r...
原创
64阅读
0评论
0点赞
发布博客于 3 年前

POJ - 3281 Dining (最大流)

#include <cstring>#include <cstdio>#include <cstdlib>#include <algorithm>#include <queue>using namespace std;typedef long long ll;int mp[505][505], vis[505], s, t...
原创
71阅读
0评论
0点赞
发布博客于 3 年前

HDU - 2089 不要62(数位DP)

模板题 #include <bits/stdc++.h>using namespace std;typedef long long ll;ll a[15];ll dp[15][2];ll dfs(ll pos, ll sta, ll lim){ if(pos == -1)return 1; if(lim == 0 && dp[pos][...
原创
122阅读
0评论
0点赞
发布博客于 3 年前

HYSBZ - 1143 祭祀river (二分图最大匹配)

#include <bits/stdc++.h>using namespace std;int a[105][105] = {0};int pre[205], s[205] = {0}, vis[105];int cat(int x, int n){ int i; for(i = 1; i <= n; i++) { if(vis...
原创
104阅读
0评论
0点赞
发布博客于 3 年前

CodeForces - 1082C Multi-Subject Competition(前缀和+思维)

题目链接:https://cn.vjudge.net/problem/CodeForces-1082C题目大意:给定n名选手,每名选手都有唯一选择的科目si和对应的能力水平。并且给定科目数量为m。求选定若干个科目,并且每个科目参与选手数量相同的情况下的最大能力水平。解题思路:首先将每个选手的能力值插入到对应的科目里面,用优先队列维护,求前缀和,不断加入的答案数组里(为负值时不加入)...
原创
195阅读
0评论
0点赞
发布博客于 3 年前

CodeForces - 1082C Multi-Subject Competition(前缀和+思维)

题目链接:https://cn.vjudge.net/problem/CodeForces-1082C题目大意:给定n名选手,每名选手都有唯一选择的科目si和对应的能力水平。并且给定科目数量为m。求选定若干个科目,并且每个科目参与选手数量相同的情况下的最大能力水平。解题思路:首先将每个选手的能力值插入到对应的科目里面,用优先队列维护,求前缀和,不断加入的答案数组里(为负值时不加入)...
原创
195阅读
0评论
0点赞
发布博客于 3 年前

CodeForces - 1088C Ehab and a 2-operation task(思维)

题目链接:https://cn.vjudge.net/problem/CodeForces-1088C题目大意:给你一个长度为 n 的序列,你可以对这个序列做如下操作:1、从 1 - i ,每个元素加一个正数 x2、从 1 - i ,每个元素 mod 一个正数 x问你能否在 n + 1 步操作内使这个序列严格递增解题思路:答案与元素没有关系,第一步 1 - n mod ...
原创
244阅读
0评论
0点赞
发布博客于 3 年前

CodeForces - 1084C The Fair Nut and String(简单DP)

题目链接:https://cn.vjudge.net/problem/CodeForces-1084C题目大意:给你一个由小写字母组成的字符串 s ,让你找一种序列:1、对于任意一个 i ,使得 s[ p[ i ] ] == 'a'2、对于任意一个 i ,存在 p[ i ] < j < p[i + 1],且s[ p[ i ] ] == 'b'求这种序列有多少个,答案...
原创
804阅读
0评论
0点赞
发布博客于 3 年前

Gym - 101982B Coprime Integers(容斥原理)

#include<bits/stdc++.h>using namespace std;typedef long long ll;ll ans, p = 0, maxx, a, b, c, d;ll prim[10000007],num[10000005];void dfs(ll x, ll sum, ll num){ if(num > maxx)retur...
原创
290阅读
0评论
1点赞
发布博客于 3 年前

Codeforces Round #523 (Div. 2)

A简单题#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n, m, ans; cin >> n >> m; ans = m / n; if(m % n != 0)ans++; cout <...
原创
66阅读
0评论
0点赞
发布博客于 3 年前

HDU - 2176 取(m堆)石子游戏 (尼姆博弈)

题目链接:https://cn.vjudge.net/contest/269106#problem/Q题目大意:        m堆石子,两人轮流取.只能在1堆中取.取完者胜.先取者负输出No.先取者胜输出Yes,然后输出怎样取子.例如5堆 5,7,8,9,10先取者胜,先取者第1次取时可以从有8个的那一堆取走7个剩下1个,也可以从有9个的中那一堆取走9个剩下0个,也可以从有10个的中那一...
原创
112阅读
0评论
0点赞
发布博客于 3 年前

HDU - 1527 取石子游戏 (威佐夫博弈)

题目链接:https://cn.vjudge.net/contest/269106#problem/R题目大意:        有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好...
原创
59阅读
0评论
0点赞
发布博客于 3 年前

HDU - 2516 取石子游戏 (斐波那契博弈)

题目链接:https://cn.vjudge.net/contest/269106#problem/F题目大意:        1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".解题思路:        斐波那契博弈,n为斐波那契数时...
原创
111阅读
0评论
0点赞
发布博客于 3 年前

HDU - 2516 取石子游戏 (斐波那契博弈)

题目链接:https://cn.vjudge.net/contest/269106#problem/F题目大意:        1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".解题思路:        斐波那契博弈,n为斐波那契数时...
原创
111阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 3339 计算长方形的周长和面积(类和对象)

import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin = new Scanner(System.in); String s; int i, l, r; whil...
原创
306阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2749 区域内点的个数

import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin = new Scanner(System.in); int n, x1, y1, x2, y2, x, y, an...
原创
251阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2670 3-1 Point类的构造函数

import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin = new Scanner(System.in); int a, b; a = cin.nextInt();...
原创
150阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2669 2-2 Time类的定义

import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner cin = new Scanner(System.in); int a, b, c; a = cin.nextInt(...
原创
124阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2562 相似三角形

import java.util.Scanner;class Judge{ double a, b, c, a1, b1, c1; Judge(double a, double b,double c, double a1, double b1, double c1) { this.a = a; this.a1 = a1; this.b = b; this.b1 = b1...
原创
237阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2444 正方形

import java.util.Scanner;class Judge{ double x1, y1, x2, y2, x3, y3, x4, y4; Judge(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { this.x1 = x1; thi...
原创
112阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2240 织女的红线

import java.util.Scanner;class Line{ double r, x, y, ans; int num; Line(int n, double ri, double xi, double yi) { num = n; r = ri; x = xi; y = yi; ans = 0; } void AddPoint(double xi...
原创
167阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2174 回文时间

import java.util.Scanner;class Time{ int a, b, c, d; Time(String s) { char ci[] = s.toCharArray(); a = ci[0] - '0'; b = ci[1] - '0'; c = ci[3] - '0'; d = ci[4] - '0'; } void Print()...
原创
144阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2138 数据结构实验之图论三:判断可达性

#include <stdio.h>#include <string.h>#include <stdlib.h>int a[1005][1005];int vis[1005];int qu[100005], front, tail;void init(){ memset(a, 0, sizeof(a)); memset(vis, ...
原创
278阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2107 数据结构实验之图论二:图的深度遍历

#include <stdio.h>#include <string.h>#include <stdlib.h>int a[105][105];int vis[105];int qu[10005], front, tail, flag, n;void init(){ memset(a, 0, sizeof(a)); memset(...
原创
174阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2141 数据结构实验之图论一:基于邻接矩阵的广度优先搜索遍历

#include <stdio.h>#include <string.h>#include <stdlib.h>int a[105][105];int vis[105];int qu[10005], front, tail;void init(){ memset(a, 0, sizeof(a)); memset(vis, 0, s...
原创
153阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 3345 数据结构实验之二叉树六:哈夫曼编码

#include <stdio.h>#include <string.h>#include <stdlib.h>int a[10005], p;char data[10005];int vis[10005];void sort(int l, int r){ int i, j; for(i = r - 1; i >= l; i...
原创
196阅读
0评论
1点赞
发布博客于 3 年前

SDUT- 3346 数据结构实验之二叉树七:叶子问题

#include <stdio.h>#include <string.h>#include <stdlib.h>char a[105];int p, len;struct node{ char data; struct node *l, *r;};struct node *qu[10005];int front = 0, ta...
原创
103阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 3344 数据结构实验之二叉树五:层序遍历

#include <stdio.h>#include <string.h>#include <stdlib.h>char a[105];int p, len;struct node{ char data; struct node *l, *r;};struct node *qu[10005];int front = 0, ta...
原创
131阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 3343 数据结构实验之二叉树四:(先序中序)还原二叉树

#include <stdio.h>#include <string.h>#include <stdlib.h>char a[105], b[105];int n;struct node{ char data; struct node *l, *r;};int max(int a, int b){return a > b ...
原创
213阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2253 分数加减法

import java.util.Scanner;class Number{ String s; int a, b, c, d; char x; Number(String s) { this.s = s; ToData(); } void ToData() { int i; a = b = c = 0; char si[] = s.toCharArray...
原创
214阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2400 高中数学?

import java.util.Scanner;class Number{ int a, b; Number(int z, int x) { a = z; b = x; } void Print(int x) { if(x == 1)System.out.println(a); else if(x == 2)System.out.println(b); el...
原创
292阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3341 数据结构实验之二叉树二:遍历二叉树

#include <stdio.h>#include <string.h>#include <stdlib.h>char a[105];int p, len;struct node{ char data; struct node *l, *r;};struct node *qu[10005];int front = 0, ta...
原创
147阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3342 数据结构实验之二叉树三:统计叶子数

简单写法:#include <stdio.h>#include <stdlib.h>#include <string.h>char a[1005];int main(){ int num, i, len; while(gets(a)) { len = strlen(a); num = 0;...
原创
206阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 2101 正方形面积

import java.util.Scanner;public class Main { static int S(int r) { return r * r; } public static void main(String[] args) { Scanner cin = new Scanner(System.in); int r; while(cin.hasNex...
原创
371阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 1588 圆的面积

import java.util.Scanner;public class Main { static double S(double r) { return 3.141592653 * r * r; } public static void main(String[] args) { Scanner cin = new Scanner(System.in); int t...
原创
108阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 1140 面向对象程序设计上机练习一(函数重载)

import java.util.Scanner;public class Main { static int Max(int a[]) { int ans = a[0]; for(int i = 0; i < 5; i++)if(a[i] > ans)ans = a[i]; System.out.println(ans); return ans; } s...
原创
121阅读
0评论
0点赞
发布博客于 3 年前

SDUT- 1133 C/C++经典程序训练3---模拟计算器

import java.util.Scanner;class Number{ int a, b; String c; Number(int n, int m, String k) { a = n; b = m; c = k; } void Print() { int ans = 0; if(c.equals("+"))ans = a + b; else ...
原创
199阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 4303 简单的复数运算(类和对象)

import java.util.Scanner;class Number{ int a, b; Number() { a = b = 0; } Number(int n, int m) { a = n; b = m; } void Print() { System.out.println(a + " " + b); } void Does(int c,...
原创
294阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2055 来淄博旅游

import java.util.Scanner;class List{ String from[][] = new String[105][2105]; String to[][] = new String[105][2105]; int len1 = 0, len2 = 0; int lens1[] = new int[105]; int lens2[] = new int[1...
原创
258阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2053 整理音乐

import java.util.Scanner;class List{ String name[] = new String[100005]; int score[] = new int[100005]; int len; void SetLen(int n) { len = n; } void sort(int l, int r) { if(l >= r)r...
原创
154阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2499 数字

import java.util.Scanner;class Number { long l, r; void SetNum(long n, long m) { l = n; r = m; } long F(long n) { if(n <= (long)2)return 0; else { long x; if((long)Math.sqr...
原创
321阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 1131 C/C++训练1---最大公约数与最小公倍数

import java.util.Scanner;class Number { int a, b; Number(int n, int m) { a = n; b = m; } int GetGcd() { int ai = a, bi = b; while(bi > 0) { int x = ai; ai = bi; bi = x % ...
原创
300阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3340 数据结构实验之二叉树一:树的同构

#include <stdio.h>#include <stdlib.h>struct node{ char data; int l, r;}a[15], b[15];int check(int i, int j){ if(a[a[i].l].data == b[b[j].l].data && a[a[i].r].dat...
原创
362阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3665 顺序表应用8:最大子段和之动态规划法

#include <stdio.h>#include <stdlib.h>int *a;int max(int a, int b){return a > b ? a : b;}void creat(int n){a = (int *)malloc((n + 5)*sizeof(int));}void get(int n){for(int i = 1; i ...
原创
259阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3664 顺序表应用7:最大子段和之分治递归法

#include <stdio.h>#include <stdlib.h>int *a, cou = 0;int max(int a, int b){if(a > b)return a; else return b; }void creat(int n){ a = (int *)malloc((n + 5) * sizeof(n));}void...
原创
369阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3330 顺序表应用6:有序顺序表查询

#include <stdio.h>#include <stdlib.h>struct node{ int *h, len, size;}list;void creat(int n){ list.h = (int *)malloc((n + 5) * sizeof(int));}void get(int n){ for(int i...
原创
260阅读
0评论
0点赞
发布博客于 3 年前

SUDT - 3329 顺序表应用5:有序顺序表归并

#include <stdio.h>#include <stdlib.h>struct node{ int *h, len, size;}list1, list2, list;void creat(int n, int m){ list1.h = (int*)malloc((n + 5) * sizeof(int)); list2.h ...
原创
172阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3663 顺序表应用4-2:元素位置互换之逆置算法(数据改进)

#include <stdio.h>#include <stdlib.h>struct node{ int *h, len, size;}list;void creat(){ list.h = (int *)malloc(1000005 * sizeof(int));}void get(int n){ for(int i = 1;...
原创
383阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3326 顺序表应用3:元素位置互换之移位算法

#include <stdio.h>#include <stdlib.h>struct node{ int *h, len, size;}list;void creat(){ list.h = (int *)malloc(2000005 * sizeof(int));}void get(int n){ for(int i = 1;...
原创
234阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3325 顺序表应用2:多余元素删除之建表算法

#include <stdio.h>#include <stdlib.h>struct node{ int *h, len, size;}list;void creat(){ list.h = (int *)malloc(10005 * sizeof(int));}void get(int n){ for(int i = 1; i...
原创
497阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3324 顺序表应用1:多余元素删除之移位算法

#include <stdio.h>#include <stdlib.h>struct node{ int *h, len, size;};int main(){ int t, n, i, j, k; scanf("%d", &t); while(t--) { scanf("%d", &n...
原创
739阅读
0评论
0点赞
发布博客于 3 年前

POJ - 3737 UmBasketella (计算几何&&一阶求导)

#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#define pi 3.1415926using namespace std;int main(){ double s; while(scanf("%lf", &s) !...
原创
88阅读
0评论
0点赞
发布博客于 3 年前

HYSBZ - 1012 最大数maxnumber (线段树)

#include <bits/stdc++.h>#define ll long long#define maxn 200005using namespace std;struct node{ ll left, right; ll maxx;};node tree[maxn << 2];ll a[maxn] = {0};ll n;ll p...
原创
86阅读
0评论
0点赞
发布博客于 3 年前

CodeChef - SQUIRREL Squirrel and chestnut (二分答案)

#include <bits/stdc++.h>using namespace std;#define ll long longll T[10000007];ll P[10000007];ll ans[10000007];ll n, m, k;bool cmp(ll a, ll b){return a > b;}ll check(ll ti){ ll ...
原创
74阅读
0评论
0点赞
发布博客于 3 年前

51Nod 1640 天气晴朗的魔法 (最大生成树&&最小生成树)

#include <bits/stdc++.h>using namespace std;typedef long long ll;struct node{ ll u, v, w;}edge[200005];bool cmp(struct node a, struct node b){ return a.w < b.w;}bool cmp2(st...
原创
71阅读
0评论
0点赞
发布博客于 3 年前

51Nod - 1001 数组中和等于K的数对 (哈希&&map)

#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream>#include <algorithm>#include <stack>#include <queue&
原创
97阅读
0评论
0点赞
发布博客于 3 年前

POJ - 1321 棋盘问题 (深度优先搜索)

#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream>#include <algorithm>#include <stack>#include <queue&
原创
101阅读
0评论
0点赞
发布博客于 3 年前

HDU - 1108 最小公倍数 (欧几里得算法)

#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <map>#include <queue>#include <set>#include <cmath>u
原创
96阅读
0评论
0点赞
发布博客于 3 年前

POJ - 1703 Find them, Catch them (种类并查集)

#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>using namespace std;int pre[300000];int fin(int a){ if (pre[a]==a) return a; int t=a;...
原创
54阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3347 数据结构实验之数组三:快速转置

#include <stdio.h>#include <stdlib.h>using namespace std;struct node{ int x, y, c;}a[1005];int main(){ int n, m, q, i, j; while(scanf("%d %d %d", &n, &m, &q...
原创
188阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2130 数据结构实验之数组一:矩阵转置

#include <stdio.h>#include <stdlib.h>using namespace std;int a[105][105];int main(){ int n, m, i, j; while(scanf("%d %d", &n, &m) != EOF) { for(i = 1; i &...
原创
151阅读
1评论
0点赞
发布博客于 3 年前

ACM国际大学生程序设计竞赛:算法与实现俞勇PDF完整版

ACM国际大学生程序设计竞赛:算法与实现俞勇PDF完整版
rar
发布资源于 3 年前

SDUT - 3311 数据结构实验之串三:KMP应用

#include <stdio.h>#include <stdlib.h>#include <string.h>int a[10000005], b[10000005], nex[10000005];void pre(int a[], int n){ int i, j; i = 0; j = nex[0] = -1; ...
原创
216阅读
2评论
0点赞
发布博客于 3 年前

SDUT - 2772 数据结构实验之串一:KMP简单应用

#include <stdio.h>#include <stdlib.h>#include <string.h>char a[1000005], b[1000005];int next[1000005];void pre(char a[], int n){ int i, j; j = next[0] = -1; i = 0;...
原创
212阅读
0评论
0点赞
发布博客于 3 年前

JAVA语法练习

SDUT - 2543 整除import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner cin = new Scanner( System.in ); int n, i; int a[] = new int [10000005]; a[1] ...
原创
342阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2088 数据结构实验之栈与队列十一:refresh的停车场

#include<stdio.h>#include<string.h>#include<stdlib.h>char a[10005][15], b[10005][15], s[15];int main(){ int n, m, i, j, flag, sum1, sum2; while(scanf("%d%d",&m,&amp...
原创
404阅读
1评论
1点赞
发布博客于 3 年前

SDUT - 2449 数据结构实验之栈与队列十:走迷宫

#include <stdio.h>#include <stdlib.h>int a[15][15], dp[15][15], m, n, ans;void dfs(int x, int y){ if(x == n && y == m){ans++; return ;} dp[x][y] = 1; if(x - 1 >...
原创
248阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 1479 数据结构实验之栈与队列九:行编辑器

#include <stdio.h>#include <string.h>#include <stdlib.h>char s[1005], a[1005];int p = 0;int max(int a, int b){return a > b ? a : b;}int main(){ int len, i; while(g...
原创
431阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3335 数据结构实验之栈与队列八:栈的基本操作

#include <stdio.h>#include <stdlib.h>int a[105], p = 0;int main(){ int t, n, m, i, k, data; char cmd; scanf("%d", &t); while(t--) { p = 0; scan...
原创
221阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3334 数据结构实验之栈与队列七:出栈序列判定

#include <stdio.h>#include <string.h>int num[10005], a[10005], p = 0, q = 0;int main(){ int n, i, j, k, m, t; scanf("%d", &n); for(i = 0; i < n; i++)scanf("%d", &am...
原创
140阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3333 数据结构实验之栈与队列六:下一较大值(二)

#include <stdio.h>#include <stdlib.h>#include <string.h>struct node{ int data, next;}s[100005], *a[100005];int p = 0;int main(){ int t, n, i; scanf("%d", &t)...
原创
143阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 3332 数据结构实验之栈与队列五:下一较大值(一)

#include <stdio.h>#include <stdlib.h>#include <string.h>struct node{ int data, next;}s[100005], *a[100005];int p = 0;int main(){ int t, n, i; scanf("%d", &t)...
原创
147阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2134 数据结构实验之栈与队列四:括号匹配

#include <stdio.h>#include <string.h>char a[1005], s[1005];int p = 0;int main(){ char c; while(gets(s)) { p = 0; int len = strlen(s), i; for(i = 0...
原创
354阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2133 数据结构实验之栈与队列三:后缀式求值

#include <stdio.h>#include <string.h>int a[1005];int p = 0;int main(){ char c; while((c = getchar()) != EOF) { if(c == '#') { printf("%d
", a...
原创
185阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2132 数据结构实验之栈与队列二:一般算术表达式转换成后缀式

#include <stdio.h>#include <string.h>char a[1005], b[1005], p1 = 0, p2 = 0;int main(){ char c, t; int i; while((c = getchar()) != EOF) { if(c == '#') {...
原创
157阅读
0评论
0点赞
发布博客于 3 年前

SDUT - 2131 数据结构实验之栈与队列一:进制转换

#include <stdio.h>#include <string.h>int a[1005], p = 0;int main(){ int n, i, m; scanf("%d %d", &n, &m); if(n == 0){printf("0
"); return 0;} while(n) { ...
原创
238阅读
0评论
1点赞
发布博客于 3 年前

SDUt - 2054 数据结构实验之链表九:双向链表

#include <stdio.h>#include <stdlib.h>struct node{ int data; struct node *last, *next;};int main(){ int n, i, m, k; scanf("%d %d", &n, &m); struct node *h...
原创
263阅读
0评论
2点赞
发布博客于 3 年前

SDUT - 3712 插入排序

#include <stdio.h>#include <stdlib.h>struct node{ int data; struct node *next;};int main(){ int n, i, m; while(scanf("%d", &n) != EOF) { struct node ...
原创
159阅读
0评论
1点赞
发布博客于 3 年前