- 博客(147)
- 收藏
- 关注
转载 分页与分段
一. 分页存储管理1.基本思想用户程序的地址空间被划分成若干固定大小的区域,称为“页”,相应地,内存空间分成若干个物理块,页和块的大小相等。可将用户程序的任一页放在内存的任一块中,实现了离散分配。分页存储管理的地址机构15 12 11 0 页号P 页内位移量W页号4位,每个作业最多2的4次方=16
2017-01-10 21:51:40
628
原创 Linux下进程同步问题小例
以下代码利用mmap给内存文件分配空间,利用fork产生父子进程,通过semaphore中的信号量进行同步和死锁操作。完成了父子进程的同步运行。#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <semaphore.h>#include <sys/mman.h>int* count = 0;sem_t *mu
2017-01-03 10:15:11
548
原创 linux 下C编程链接mysql数据库
现在有一个名为sql.c的文件中链接了mysql数据库,在bash命令下编译该文件,需要:gcc sql.c -o sql -I/usr/include/mysql -L/usr/lib64/mysql -lmysqlclient
2016-12-31 18:37:56
662
原创 Linux下用C++实现ls命令
介绍:ls命令的功能是显示在当前目录下的所有文件,是最基本的命令之一。 ls命令: http://baike.baidu.com/link?url=2edNUDc5em0OmD7CugYQmgnEedFRcNioIKX8oD_32Md8zq_osLtcEKWMhrNaCxEjwaRafa6noT02ABoRxgrGL_ 我们可以类似地通过使用dirent类和dirent结构体获取当前目录下的所
2016-12-29 19:17:26
3517
转载 如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境
转载自http://www.cnblogs.com/zakun/p/5840073.html在网上搜资料,自己在本地虚拟机上尝试搭建,弄了整整一天一夜,终于弄好了. 网上的资料,虽然很多,但大多都是重复的,拿去试了之后,又很多都不能得到正确的结果.最终找到了适合我的linux环境的搭建方式;在这里贴出来:度娘真不给力啊,没搜出来靠谱的方法。最后用喜乐搜找到的靠谱的教程。这里还是要总结一下我的LAM
2016-11-30 18:28:46
746
原创 HDU 5988 Coding Contest 最小费用流变形
题目描述:Problem Description A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks, and there would be M directed paths linking these
2016-11-29 20:57:46
1016
1
转载 堆和栈的区别(转过无数次的文章)
一、预备知识—程序的内存分配 一个由C/C++编译的程序占用的内存分为以下几个部分 1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其 操作方式类似于数据结构中的栈。 2、堆区(heap) — 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回 收 。注意它与数据结构中的堆是两回事,分配方式倒是类似
2016-11-29 15:46:25
227
转载 澄清P问题、NP问题、NPC问题的概念
此文转自http://www.matrix67.com/blog/archives/105你会经常看到网上出现“这怎么做,这不是NP问题吗”、“这个只有搜了,这已经被证明是NP问题了”之类的话。你要知道,大多数人此时所说的NP问题其实都是指的NPC问题。他们没有搞清楚NP问题和NPC问题的概念。NP问题并不是那种“只有搜才行”的问题,NPC问题才是。好,行了,基本上这个误解已经被澄清了。下面的内容都
2016-11-24 19:12:45
437
原创 HDU 5938 Four Operations 想法题
题目描述:Problem Description Little Ruins is a studious boy, recently he learned the four operations!Now he want to use four operations to generate a number, he takes a string which only contains digits ‘
2016-10-31 20:17:50
865
原创 HDU 5952 Counting Cliques 暴力搜索
题目描述:Problem Description A clique is a complete graph, in which there is an edge between every pair of the vertices. Given a graph with N vertices and M edges, your task is to count the number of cliq
2016-10-30 19:57:12
2335
1
原创 Codeforces Gym 101138C Stickmen 暴力搜索+组合数
题目描述:Limak is a little bear who loves to play with graphs. Recently, he defined a new structure in a graph and called it a stickman.A stickman is a set of 7 different vertices and 6 edges. Vertices sho
2016-10-28 16:19:31
625
原创 HDU 5469 Antonidas dfs减枝
题目描述:Problem Description Given a tree with N vertices and N−1 edges. Each vertex has a single letter Ci. Given a string S, you are to choose two vertices A and B, and make sure the letters catenated o
2016-10-26 21:04:34
347
原创 UVA 6907 Body Building Tarjan找桥
题目描述: 题目分析:给定一个哑铃图的定义:由两个相同的完全图和一个桥构成。如题目描述的A图B图和C图。 给一个图(有可能不连通),求有多少个哑铃图。这题的n和m太小了,所以可以暴力每一条边,把这条边当做桥。 也可以用tarjan求桥。 最后就是判定桥两边的子图是否是相同的完全图,也就是他们的边数和点数是否相等,并且边数和点数满足完全图条件就可以。 分别以桥的两个端点,一个当做
2016-10-24 21:14:22
333
原创 UVA 6906 Cluster Analysis 水
题目描述: 题目分析:给一个n个数的序列,和一个数k,在这n个数中寻找多少个集合,其中所有数的差不超过k。排序,贪心找就可以。代码如下:#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>const int MAXN=110;using namespace std;int T,n,k;in
2016-10-24 21:02:18
306
原创 UVA 6910 Cutting Tree 并查集
题目描述:Tree in graph theory refers to any connected graph (of nodes and edges) which has no simple cycle, while forest corresponds to a collection of one or more trees. In this problem, you are given a f
2016-10-21 12:40:07
432
原创 HDU 2977 Color Squares BFS
题目描述:Problem Description You have a 3 * 3 board of color squares. Each square is either empty or has a block in it. Initially, all the squares are empty. There are four kinds of blocks: blue (B), red
2016-10-18 21:53:14
389
原创 二分图染色模板
#include <iostream>#include <cstdio>#include <cstring>#include <vector>using namespace std;const int MAX_V = 205;vector<int> G[MAX_V]; // 图int V; // 顶点数int color[MAX_V]; //
2016-10-17 19:28:37
887
原创 UVA 6862 Triples 想法题
题目描述:Mr. A invites you to solve the following problem: “Let be m and n two positive integers, 5 ≤ m ≤ 100, 2 ≤ n ≤ 100. Consider the following sets of triples: Tm.j = {(x, y, z) ∈ IN3 |x ≤ y ≤ z ≤ m
2016-10-17 11:33:34
371
原创 UVA 6855 Banks 思维题
题目描述:On Wall Street from Wonderland, we have n banks, with 10000 > n > 0. Each bank has exactly two neighbours, the left (L) and right (R) neighbour. The first bank’s left neighbour is the last bank,
2016-10-17 10:37:57
714
原创 HDU 5092 Seam Carving DP
题目描述:Problem Description Fish likes to take photo with his friends. Several days ago, he found that some pictures of him were damaged. The trouble is that there are some seams across the pictures. So
2016-10-13 20:02:20
522
原创 数位DP!!!(hdu3555 hdu2089 hdu5898 2016弱校10.5 I)
博客描述:各种数位DP,均是用模板做的。先把模板一放!// pos = 当前处理的位置(一般从高位到低位)// pre = 上一个位的数字(更高的那一位)// status = 要达到的状态,如果为1则可以认为找到了答案,到时候用来返回,// 给计数器+1。// limit = 是否受限,也即当前处理这位能否随便取值。如567,当前
2016-10-13 11:41:48
521
原创 10.3 弱校 D Parentheses 思维题
题目描述:https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/D题目分析:大意就是输入一个数n,创造一个只有’(‘和’)’的序列,并且恰好最少用n步将这个序列成为合法的括号序列(也就是每一个括号都能配对)。并且这个序列必须是越短越好,而且字典序最小(左括号字典序小于右括号字典序)。 由于各种条件限制,这个构造是唯一的。 我们可以
2016-10-03 19:48:33
308
原创 10.3 弱校 B Help the Princess! 搜索
题目描述:https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/B题目分析:由于题目是pdf格式给出的 我就扔连接算了~~ 题目大意就是一个n*m的地图,其中有一个’@’表示公主,有若干个’$’表示士兵,一个’%’表示出口,’#’表示墙(无法进入),’.’表示可以走的地方。其中公主想要逃亡到出口,有士兵追击,若公主能够走到出口且没有
2016-10-03 19:23:50
370
原创 51NOD 1006 最长公共子序列 动态规划
题目描述:给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为:abcicba abdkscabab是两个串的子序列,abc也是,abca也是,其中abca是这两个字符串最长的子序列。Input 第1行:字符串A 第2行:字符串B (A,B的长度 <= 1000)Output 输出最长的子序列,如果有多个,随意输出1个。Input示例abcicbaab
2016-09-25 21:30:31
1274
原创 HDU 5889 Barricade 最短路+网络流
题目描述:Problem Description The empire is under attack again. The general of empire is planning to defend his castle. The land can be seen as N towns and M roads, and each road has the same length and co
2016-09-24 11:56:38
290
原创 HDU 5883 The Best Path 欧拉图
题目描述:Problem Description Alice is planning her travel route in a beautiful valley. In this valley, there are N lakes, and M rivers linking these lakes. Alice wants to start her trip from one lake, and
2016-09-19 12:57:27
317
原创 Gym 100703A Tea-drinking 最小生成树
题目描述:Description Castles Valley was lit by the noonday sun. One could descry two figures on a balcony of one of Castles — a big and a small ones. Dragon and Princess were drinking tea. Dragon was fond
2016-09-19 12:39:34
267
原创 SCU 4444 Travel 完全图的最短路求法
题目描述:The country frog lives in has nn towns which are conveniently numbered by 1,2,…,n1,2,…,n.Among n(n−1)2n(n−1)2 pairs of towns, mm of them are connected by bidirectional highway, which needs aa minu
2016-09-12 20:57:15
827
原创 HDU5876 Sparse Graph 补图的最短路
题目描述:Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such that two distinct vertices of H are adjacent if and only if they are not adjacent in G. Now
2016-09-12 09:51:47
336
原创 POJ 1679 The Unique MST 次小生成树
题目描述:Description Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undirected graph G = (V, E). A spanning tree of G
2016-08-16 21:17:41
378
原创 POJ 2485 Highways 最小生成树的最大边
题目描述:Description The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this pro
2016-08-16 21:13:43
358
原创 URAL 2019 Pair: normal and paranormal 暴力?
题目描述:Description If you find yourself in Nevada at an abandoned nuclear range during Halloween time, you’ll become a witness of an unusual show. Here Ghostbusters hold annual tests for new versions of
2016-08-13 21:07:15
441
原创 HDU 5831 Rikka with Parenthesis II
题目描述:Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:Correct parentheses sequences can
2016-08-13 20:03:30
514
原创 URAL 2018 The Debut Album DP中滚动数组用法
题目描述:Description Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes. The pr
2016-08-13 19:34:39
583
原创 HDU 5818 Joint Stacks 模拟
题目描述:Problem Description A stack is a data structure in which all insertions and deletions of entries are made at one end, called the “top” of the stack. The last entry which is inserted is the first
2016-08-13 11:19:26
303
原创 Codeforces Gym100531D Digits 暴力
题目描述:Little Petya likes integers. Recently he has learned about different properties of sums of number’s digits. For example, if the sum of number’s digits is divisible by 9, then the number itself is
2016-08-08 21:34:39
425
原创 HDU 5024 Wang Xifeng's Little Plot 暴搜
题目描述:Problem Description 《Dream of the Red Chamber》(also 《The Story of the Stone》) is one of the Four Great Classical Novels of Chinese literature, and it is commonly regarded as the best one. This no
2016-08-08 19:49:59
437
原创 HDU 5795 A Simple Nim SG函数打表找规律
题目描述:Problem Description Two players take turns picking candies from n heaps,the player who picks the last one will win the game.On each turn they can pick any number of candies which come from the sa
2016-08-06 19:50:36
387
原创 HDU 5783 Divide the Sequence 思维题
题目描述:Problem Description Alice has a sequence A, She wants to split A into as much as possible continuous subsequences, satisfying that for each subsequence, every its prefix sum is not small than 0.I
2016-08-06 18:59:34
524
原创 HDU 5791 Two DP
题目描述:Problem Description Alice gets two sequences A and B. A easy problem comes. How many pair of sequence A’ and sequence B’ are same. For example, {1,2} and {1,2} are same. {1,2,4} and {1,4,2} are n
2016-08-04 10:20:03
540
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人