摘要:1.sort头文件:algorithm(1)有数组a[n],通过sort(a,a+n),可以将数列从a[0]到a[n-1]排序;通过sort(a+1,a+n-1)可以将数列由a[1]到a[n-2]排序。默认是从小到大排序。(2)如果希望从大到小排序或者按照其他规则排序可以设置比较函数。排序对象:struct Group
{ int s,e,idx;
}a[5001];比较函数:bool cmp(Group x, Group y)
{ if(x.e!=y.e) return x.e<y.e;//从小到大排序 else if(x.s!=y.s) return x.s<y.s...
阅读全文
摘要:B. Sysadmin Bobtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEmail address in Berland is a string of the formA@B, whereAandBare arbitrary strings consisting of small Latin letters.Bob is a system administrator in «Bersoft» company. He
阅读全文
摘要:Worms Evolutiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputProfessor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There arenforms of worms. Worms of these forms have lengthsa1
阅读全文
摘要:A. Hexadecimal's theoremtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not n
阅读全文
摘要:D. Prizes, Prizes, more Prizestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya, like many others, likes to participate in a variety of sweepstakes and lotteries. Now he collects wrappings from a famous chocolate bar "Jupiter". Acco
阅读全文
摘要:B. Solitairetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA boy named Vasya wants to play an old Russian solitaire called "Accordion". In this solitaire, the player must observe the following rules:A deck ofncards is carefully shuffle
阅读全文
摘要:迭代器是指向数据集合(比如数组、容器)中的元素的数据类型,它可以通过一系列的操作(如自增运算符++,取值运算符*)遍历数据集合中的元素。 迭代器的一种显著形式是指针。指针可以指向数组中的元素,可以通过自增操作“++”遍历数组中的元素。此外迭代器还有其他形式,例如,每一种类型的容器,如vector,都设置有一个特定形式的“iterator”用于高效低遍历其中的元素。 注意,虽然指针是一种典型的迭代器,但并非所有的迭代器都具有与指针相同的功能。指针具有一些迭代器所不需要具有的功能。 迭代器存在五个分类,这五个类别是根据迭代器所执行的功能划分的,五个类别分别是:输入迭代器,输出迭代器,随机...
阅读全文
摘要:优先队列是一种容器适配器(容器适配器的概念本人不会解释,故此处无法作出说明),它的第一个元素(位于头部top)总是队列中最大的元素,这里的“最大”是指队列元素的严格弱序中的“最大”。严格弱序是一系列数或事物按照一定的比较关系“<”排列得出的序列,“<”可以是数学中进行数值比较的大于,也可以是小于,还可以是其它含义,这大概与离散数学中的“偏序关系”相仿。 在内存充足的情况下,优先队列能被无限地插入元素。 优先队列作为一个容器适配器,它使用其它容器作为底层容器,并提供一系列访问元素的函数。优先队列中的元素从底层容器的“尾部(back)”弹出,即是从队列的顶部(top)弹出。底层容器需要
阅读全文
摘要:CSDN的文字编辑功能实在不敢恭维,于是只能在博客园写长文章。1.Priority_queue:http://www.cnblogs.com/cszlg/archive/2012/07/27/2611607.html后续内容之后补充
阅读全文
摘要:非主流Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeFZU 1922Description非主流指不属于主流的事物,如文化上的次文化,宗教上的异端,人群中的异类等。非主流是相对于主流而存在概念。一个事物既可以从非主流变成主流,也可以从主流变为非主流。因此,没有绝对的主流,也不会有绝对的非主流。福大新校区的周围有若干个养鸭场,当然鸭群里面也有另类的。养鸭场的老板认为,这些另类的鸭子,要么可以卖个好价钱,要么一文不值。我们定义每只鸭子的特征为一个一维的0-1向量如:
阅读全文
摘要:A. Dubsteptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from
阅读全文
摘要:1002. Anti-prime Sequences Total:3346Accepted:1220Rating:3.5/5.0(54 votes)Time Limit: 3sec Memory Limit:32MB DescriptionGiven a sequence of consecutive integers n,n+1,n+2,...,m, an anti-prime sequence is a rearrangement of these integers so that each adjacent pair of integers sums to a composite (n.
阅读全文
摘要:Classified Problems on Online Judge 练习题选自以下在线测评系统 * sicily:http://soj.me, 中山大学Sicily在线测评系统 * UVA OnlineJudge, 题号前缀为uva * ProgrammingChanlanges Online Judge, 题号前缀为pc题目的分类仅供参考,很多题目有多种实现,有些题目比较综合,所以或许有不确切或不正确的分类,发现问题请提醒我。1. 编程入门2. 数据结构3. 字符串4. 排序5. 算术与代数6. 组合问题7. 数论8. 搜索: 回溯法,启发式搜索9. 图遍历10. 图算法11. 动态规划
阅读全文
摘要:统计难题Time Limit: 4000/2000 MS (Java/Others)Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 10043Accepted Submission(s): 4077Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统
阅读全文
摘要:ASCII码表ASCII值控制字符ASCII值控制字符ASCII值控制字符ASCII值控制字符0NUT32(space)64@96、1SOH33!65A97a2STX34”66B98b3ETX35#67C99c4EOT36$68D100d5ENQ37%69E101e6ACK38&70F102f7BEL39,71G103g8BS40(72H104h9HT41)73I105i10LF42*74J106j11VT43+75K107k12FF44,76L108l13CR45-77M109m14SO46.78N110n15SI47/79O111o16DLE48080P112p17DCI49181
阅读全文
摘要:1.识别空行。gets(string), if(strlen(string)==0)则是空行2.结构体的初始化函数可以放在结构体中,这样可以方便地根据需要对某一个节点进行初始化3.常见简写:ans(answer),cnt(count),idx(index,下标),init(initial),str(string),pos(position,位置)4.生成随机数简单的方法:#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{ for(int i=0;i<5;i++) cout
阅读全文
摘要:Round and Round We GoTime Limit:1000MSMemory Limit:10000KTotal Submissions:10410Accepted:4766DescriptionA cyclic number is an integer n digits in length which, when multiplied by any integer from 1 to n, yields a"cycle"of the digits of the original number. That is, if you consider the numb
阅读全文
摘要:问题提出:n个人(编号1~n)围成一个圈,从1开始依次报数,报到m的出列,剩下的人继续从1开始报数(由刚出列的人的下一个人开始)。求最后出列的人(胜利者)的编号。为了讨论方便,先把问题稍微改变一下,并不影响原意:问题描述:n个人(编号0~(n-1)),从0开始报数,报到(m-1)的退出,剩下的人继续从0开始报数。求胜利者的编号。我们知道第一个人(编号一定是m%n-1)出列之后,剩下的n-1个人组成了一个新的约瑟夫环(以编号为k=m%n的人开始):k k+1 k+2 ... n-2, n-1, 0, 1, 2, ... k-2,并且从k开始报0。现在我们把他们的编号做一下转换:k -->
阅读全文
摘要:单词数Time Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15421Accepted Submission(s): 4010Problem Descriptionlily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数。下面你的任务是帮助xiaoou333解决这个问题。Input有多组数据,每组一行,每组就是一篇小文章。每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束。Outp
阅读全文
摘要:F -志愿者选拔Time Limit:1500MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusPracticeFZU 1894Description世博会马上就要开幕了,福州大学组织了一次志愿者选拔活动。参加志愿者选拔的同学们排队接受面试官们的面试。参加面试的同学们按照先来先面试并且先结束的原则接受面试官们的考查。面试中每个人的人品是主要考查对象之一。(提高人品的方法有扶老奶奶过街,不闯红灯等)作为主面试官的John想知道当前正在接受面试的同学队伍中人品值最高的是多少。于是他请你帮忙编写一个程序来计算。Inp
阅读全文
摘要:发生错误的程序:#include <stdio.h>#include <string.h>#include <algorithm>int cmp(const void* x,const void* y){ struct word* xx=(word*)x; struct word* yy=(word*)y; return strcmp(xx->a,yy->a);}struct word{ char a[26];}w[1000];int main(){……}错因:结构体的声明和定义在cmp函数之后
阅读全文
摘要:转载,并经过本人补充cin、cin.get()、cin.getline()、getline()、gets()等函数的用法2007/10/27 22:51学C++的时候,这几个输入函数弄的有点迷糊;这里做个小结,为了自己复习,也希望对后来者能有所帮助,如果有差错的地方还请各位多多指教(本文所有程序均通过VC 6.0运行)转载请保留作者信息;1、cin1、cin.get()2、cin.getline()3、getline()4、gets()5、getchar()1、cin>>用法1:最基本,也是最常用的用法,输入一个数字:#include <iostream>using n
阅读全文
摘要:B. Squaretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a square painted on a piece of paper, the square's side equalsnmeters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corne
阅读全文
摘要:1.当n是short int ,m是long long int时,语句m=4*n,使用GNU,得到的m是short int的范围,因此当n稍大时,m就可能溢出。2.输出字符串时,遇到‘\0’结束输入,如果没有适当地设置'\0',可能会出现问题。比如有struct node{ char s[10];}n[2];如果w[0].s中没有‘\0’,则scanf("%s",n[0].s)不会只输出n[0]中字符数组s中的内容,因为这一个输出语句是输出以n[0].s为首地址直到'\0'为止的内容。3.当用memset给char型以外的数组初始化时,只能初
阅读全文
摘要:A. Examstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day the Codeforces round author sat exams. He hadnexams and he needed to get an integer from2to5for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark2.The
阅读全文
摘要:B. Walking in the Raintime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists ofntiles that are lain in a row and are numbered from1tonfrom right to left.
阅读全文
摘要:A. Funky Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as, wherekis some positive integer), and the cooles
阅读全文
摘要:IMMEDIATE DECODABILITYTime Limit:1000MSMemory Limit:10000KTotal Submissions:8811Accepted:4177DescriptionAn encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in bina
阅读全文
摘要:B. Game on Papertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne not particularly beautiful evening Valera got very bored. To amuse himself a little bit, he found the following game.He took a checkered white square piece of paper, consisting o
阅读全文
摘要:A. Two Problemstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA boy Valera registered on siteCodeforcesasValera, and wrote his firstCodeforces Round #300. He boasted to a friend Arkady about winning as much asxpoints for his first contest. But A
阅读全文
摘要:Color Me LessTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 25873Accepted: 12417DescriptionA color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires that you perform just such a mapping in a standard twenty-four bit RGB color spac.
阅读全文
摘要:原文地址:http://www.blogjava.net/spec-second/archive/2008/08/17/222609.html欧氏距离(Euclidean distance)欧氏距离定义: 欧氏距离( Euclidean distance)是一个通常采用的距离定义,它是在m维空间中两个点之间的真实距离。在二维和三维空间中的欧式距离的就是两点之间的距离,二维的公式是 d = sqrt((x1-x2)^+(y1-y2)^) 三维的公式是 d=sqrt(x1-x2)^+(y1-y2)^+(z1-z2)^) 推广到n维空间,欧式距离的公式是 d=sqrt( ∑(xi1-xi2)^ )
阅读全文
摘要:Web NavigationTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 23618Accepted: 10534DescriptionStandard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be
阅读全文
摘要:B. Little Elephant and Sortingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Elephant loves sortings.He has an arrayaconsisting ofnintegers. Let's number the array elements from 1 ton, then thei-th element will be denoted asai. The
阅读全文
摘要:A. Little Elephant and Rozdiltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Elephant loves Ukraine very much. Most of all he loves town Rozdol (ukr. "Rozdil").However, Rozdil is dangerous to settle, so the Little Elephant wa
阅读全文
摘要:BiorhythmsTime Limit:1000MSMemory Limit:10000KTotal Submissions:92184Accepted:28170DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of
阅读全文
摘要:double型:-1.7*10^308~+1.7*10^308char -128 ~ 127 (1 Byte)short -32767 ~ 32768 (2 Bytes)unsigned short 0 ~ 65536 (2 Bytes)int -2147483648 ~ 2147483647 (4 Bytes)unsigned int 0 ~ 4294967295 (4 Bytes)long == intlong long -9223372036854775808 ~ 9223372036854775807 (8 Bytes)
阅读全文
摘要:使用iskeyword函数可以列出matlab的系统关键字 1 >> iskeyword 2 3 ans = 4 5 'break' 6 'case' 7 'catch' 8 'classdef' 9 'continue'10 'else'11 'elseif'12 'end'13 'for'14 'function'15 'global'16 'if'17 'otherwise
阅读全文