自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

kalilili的专栏

岁月如歌

  • 博客(37)
  • 收藏
  • 关注

转载 STL 优先队列基础用法

基本操作:empty() 如果队列为空返回真pop() 删除对顶元素push() 加入一个元素size() 返回优先队列中拥有的元素个数top() 返回优先队列对顶元素在默认的优先队列中,优先级高的先出队。在默认的int型中先出队的为较大的数。使用方法:头文件:#include 有两种声明方式:普通方法和结构体方法,将在下面代码处解释:下面代码列出了

2014-12-28 10:02:19 618

原创 STL 算法vector/set集合-交集,并集,差集,对称差

针对这里提及的四个集合运算必须特别注意: 1、第一个算法需保证第一集合和第二集合有序,并从小到大排序,内部使用默认“2、第二个算法需保证第一集合和第二集合有序,排序方式参照Compare确定,内部使用Compare比较元素大小。1 -- set_intersection(交集)template OutputIterator set_intersection(InputIter

2014-12-26 21:13:02 22367 1

转载 string 简明教程

创建 string 对象字符串的操作,需要先用 string 类型的构造函数,构造出一个 string 对象,为随后添加的字符分配内存,并初始化 string 对象的内部变量。如下是它的几个常用的构造函数原型。1.    string()    默认的构造函数,用于创建一个不包含任何非空字符的 string 对象。    例如,下面一行代码创建空的 string 对象 s . 

2014-12-25 10:24:23 884

原创 stringstream的基本用法

stringstream是字符串流。它将流与存储在内存中的string对象绑定起来。在多种数据类型之间实现自动格式化。1 stringstream对象的使用#include#includeusing namespace std;int main(){ string line,word; while(getline(cin,line))

2014-12-24 00:37:32 1132

原创 【转】STL map

一.Map概述 Map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。这里说下map内部数据的组织,map内部自建一颗红黑树(一种非严格意义上的平衡二叉树),这颗树具有对数据自动排序的功能,所以在map内部所有的数据都是有序的

2014-12-23 23:47:40 624

转载 C++ string类

C++ string 用法详解1 string 使用其实,string并不是一个单独的容器,只是basic_string 模板类的一个typedef 而已,相对应的还有wstring, 你在string 头文件中你会发现下面的代码:extern "C++" {typedef basic_string string;typedef basic_string w

2014-12-23 20:21:58 622

原创 POJ N0.2386 Lake Counting(求连通块数量)

题目描述:有一个大小为N*M的园子,雨后积水。八连通的积水被认为是一个水洼,求园子共有多少水洼。八连通示意图(相对W的连通部分用*标记)*  *  ** W **  *  *限制条件N,M10 12W........WW..    WWW.....WWW....WW...WW..........WW......

2014-12-19 22:15:14 1018

原创 n个数的全排列的相关问题

问题类型:需要进行n个数的全排列再进行其他操作O(2^n)c++代码实现:#includeusing namespace std;int perm[11],pos,n;bool mapp[11]={0};void perm1(int pos,int n){ if(pos==n+1) { for(int k=1;k<=n;k++)

2014-12-19 21:51:37 1073

原创 POJ2362 Square

题目描述:给定一系列枝条,判断他们是否可以收尾相连接成一个正方形。样例输入:第一行是样例个数N,以下各n行是的第一个数M是这个样例的枝条数,然后后面跟着各个枝条的长度。限制条件:4每个枝条的长度between 1 and 10,000。样例i/o:Sample Input34 1 1 1 15 10 20 30 40 508 1 7 2 6 4 4

2014-12-19 21:24:43 837

原创 POJ1111 Image Perimeters(求连块周长)

题目描述有一个矩形的由 X 和 . 组成的图像,已知它的长和宽。现在给你一个坐标(保证坐标上是X),求其整个连块的周长。(连块就是连着的X,斜着有相同顶点也算)。输入长,宽,坐标X,坐标Y,接着是图。多组数据,4个0结束。样例输入7 7 4 4XXXXXXXXX...XXX..X..XX..X...X..X..XX.....XXXX

2014-12-19 21:15:14 1003

原创 部分和问题

题目表述:给定整数a1,a2,、、、an,判断是否可以从中选出若干数,使他们的和恰好为K;限制条件:1-10^8-10^8c++代码实现如下:#includeusing namespace std;int a[25];int main(){ bool dfs(int i,int sum,int k,int n); int n,k; cin>

2014-12-19 20:43:57 674

原创 钢条切割问题

(来自算法导论P204)问题描述:给定一段长度为n英寸的钢条和一个价格表Pi(i=1,2,3,...,n),求切割钢条方案,使收益rn最大。思路(递归):在钢条左边切割i段,再对右边剩余长度n-i段继续进行切割(递归求解),对左边的一段的则不再进行切割。所以有:若不做切割第一段长度为n,收益为pn,剩余部分长度为0,对应的收益ro=0;则求解公式:r(n)=max(1不

2014-12-19 17:11:24 1003

原创 不定长数组:vector

使用需要包含头文件 #include vector是一个模板类,所以需要用vector a或者vector b这种方式声明。vector的常用操作:int len = a.size();//返回vector长度 a.resize(100);//把a长度变为100 a.push_back(10)//把10添加到尾部 a.pop_back();//删除最后一个元素

2014-12-19 16:37:44 2043 1

原创 集合set

常用:begin()        ,返回set容器的第一个元素end()      ,返回set容器的最后一个元素clear()          ,删除set容器中的所有的元素empty()    ,判断set容器是否为空max_size()   ,返回set容器可能包含的元素最大个数size()      ,返回当前set容器中的元素个数

2014-12-19 16:04:38 647

原创 HDU1717循环小数化成分数

A - 萌Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 1717DescriptionRay 在数学课上听老师说,任何小数都能表示成分数的形式,他开始了化了起来,很快他就完成了,但他又想到一个问题

2014-12-06 16:20:48 1059

转载 字符数组与字符指针

//节选了一些有价值和易错的部分。char *str = "This is a string.";char string[ ]="This is a string.";字符指针str与字符数组string的区别是:str是一个变量,可以改变str使它指向不同的字符串,但不能改变str所指的字符串常量。string是一个数组,可以改变数组中保存的内容。2.实例:char

2014-12-06 00:04:23 424

原创 493A Vasya and Football

A. Vasya and Footballtime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard outputVasya has started watching football games. He has learned that

2014-12-04 16:34:35 525

原创 CF493B Vasya and Wrestling

/*B. Vasya and Wrestlingtime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard outputVasya has become interested in wrestling. In wrestling wre

2014-12-04 16:18:32 601

原创 UVAOJ401- Palindromes

/* Palindromes A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string

2014-12-04 11:53:19 557

原创 UVaOJ1368 - DNA Consensus String

/*DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It consists of four different nucleotides, namely Adenine, Thymine, Guanine, and Cytosine as shown in Figure 1. I

2014-12-03 22:37:53 516

原创 蓝桥杯第二次选拔c.Sumsets

/*c.SumsetsTime Limit: 2000MS Memory Limit: 200000KTotal Submissions: 13291 Accepted: 5324DescriptionFarmer John commanded his cows to search for different sets of numbers that sum to a given n

2014-12-03 22:36:36 795

原创 蓝桥杯第二次选拔D.Leftmost Digit

/*D.Leftmost DigitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13082 Accepted Submission(s): 5009Problem DescriptionGiven a positive

2014-12-03 22:35:42 469

原创 蓝桥杯第二次选拔E.Wooden Sticks

/*E.Wooden SticksTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11619 Accepted Submission(s): 4800Problem DescriptionThere is a pile o

2014-12-03 22:34:53 617

原创 HDUOJ lines

/*linesTime Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 590 Accepted Submission(s): 277Problem DescriptionJohn has several lines. T

2014-12-03 22:33:03 513

原创 HDUOJAlexandra and A*B Problem

/*Alexandra and A*B ProblemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 325 Accepted Submission(s): 70Problem DescriptionAlexandra

2014-12-03 22:31:42 399

原创 HDUOJAlexandra and Prime Numbers

/*Alexandra and Prime NumbersTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0Problem DescriptionAlexandra

2014-12-03 22:30:21 631

原创 NOJ1004线性表操作

/*线性表操作时间限制(普通/Java) : 1000 MS/ 3000 MS 运行内存限制 : 65536 KByte总提交 : 3107 测试通过 : 661 描述线性表是n个元素的有序集合(n30),n是线性表中元素的个数,称为线性表的长度。可以用一组地址连续的存储单元依次存储线性表中元素,采用这种存储方式的线性表称为顺序表。请在顺序表上实

2014-12-03 22:28:55 828

原创 NOJ上的大数相加

#include#includeint main(){ char a[1100],b[1100],c[1100]; int temp=0,o=0,s=0; char*p=c; scanf("%s%s",a,b); int n=strlen(a); int m=strlen(b); // printf("!%d,%d!",a[n-1],b[m-1]); if(m==n) wh

2014-12-03 22:28:41 682

原创 NOJ1030ACM程序设计之马拉松竞赛

/*ACM程序设计之马拉松竞赛时间限制(普通/Java) : 1000 MS/ 3000 MS 运行内存限制 : 65536 KByte总提交 : 1158 测试通过 : 261 比赛描述校ACM协会近四个月举行了为期100天ACM程序设计之马拉松竞赛,竞赛题总数为1000,同学们反响热烈,先后有许多ACM程序设计竞赛爱好者报名,这些选手按报名时间

2014-12-03 22:27:41 815

原创 uva455 Periodic Strings

/* Periodic Strings A character string is said to have period k if it can be formed by concatenating one or more repetitions of another string of length k. For example, the string "abcabcabcabc" has

2014-12-03 22:09:48 516

原创 UVAOJ-Digit counting

/*Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N (1 < N < 10000) . After that, he counts the numbe

2014-12-03 22:07:28 850

原创 uvaoj1339ancient cipher

/*Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form

2014-12-03 22:06:29 443

原创 uvaoj1585oxooxx得分问题

/*There is an objective test result such as ``OOXXOXXOOO". An `O' means a correct answer of a problem and an `X' means a wrong answer. The score of each problem of this test is calculated by itself an

2014-12-03 22:03:48 4993

原创 uvaoj 1586-molar mass

/*An organic compound is any member of a large class of chemical compounds whose molecules contain carbon. The molar mass of an organic compound is the mass of one mole of the organic compound. The m

2014-12-03 22:02:04 650

原创 UVAOJ133The Dole Queue

/* The Dole Queue In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every day all dole applicants will b

2014-12-03 21:46:19 428

原创 UVaOJ-213 Message Decoding

/* Message DecodingSome message encoding schemes require that an encoded message be sent in two parts. The first part, called the header, contains the characters of the message. The second part cont

2014-12-03 21:44:37 624

原创 UVAOJ489-Hangman Judge

/* Hangman JudgeIn ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the same a

2014-12-03 21:42:13 450

空空如也

空空如也

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

TA关注的人

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