自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 收藏
  • 关注

原创 POJ 1811 Prime Test【素数判定与大数分解】

题目来戳呀DescriptionGiven a big integer number, you are required to find out whether it’s a prime number.InputThe first line contains the number of test cases T (1 <= T <= 20 ), then the following T lines

2017-03-29 16:45:14 519

原创 HDU 3294 Girls' research【最长回文子串】

题目来戳呀Problem DescriptionOne day, sailormoon girls are so delighted that they intend to research about palindromic strings. Operation contains two steps: First step: girls will write a long string (onl

2017-03-27 23:25:18 345

原创 POJ 1284 Primitive Roots【欧拉函数】

题目来戳呀DescriptionWe say that integer x, 0 &lt; x &lt; p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 &lt;= i &lt;= p-1 } is equal to { 1, ..., p-1 }. For example, the...

2017-03-22 21:29:22 284

原创 C语言文件输入输出

上次复习没有复习到,这次滚回来补了○| ̄|_文件指针FILE实际上FILE是一个新的数据类型,在打开文件时必须先定义一个文件指针。1.用fopen函数打开数据文件,用fclose函数关闭数据文件。在打开文件的同时,一般都指定一个指针变量指向该文件,也就是建立起指针变量与文件之间的联系;关闭是使文件指针变量不再指向该文件。fopen(文件名,使用文件方式)fc

2017-03-19 20:13:04 401

原创 rand函数与srand函数

srand 初始化随机种子,rand 产生随机数。如果不用srand函数,每次产生的随机数列是相同的;如果用srand函数设置了种子,每次可以产生不同的随机数列。1.随机种子:随机种子是一种以随机数作为对象的以真随机数(种子)为初始条件的随机数。2.伪随机数:首先大家要知道,计算机是结构,条理非常清晰的数理逻辑.它所执行的东西都是按照人们编好的程序一步一步来的.所以它产生并

2017-03-19 16:45:24 573

原创 数论之大数分解与素数判定

写下来感觉也是没有用的哇TAT还是找模板理解吧QAQ1.Miller-rabin算法: 用来快速判断一个正整数是否为素数的算法。它利用了费马小定理,即:如果p是质数,且a,p互质,那么$a^(p-1)$%p≡1。也就是对于所有小于p的正整数a来说都应该符合$a^(p-1)$%p≡1,因为质数φ(p)=p-1。那么根据逆否命题,对于一个p,我们只要举出一个a(a&lt;p)不符合这个恒等式,则可判定...

2017-03-19 15:39:39 2416

原创 数论之欧几里得与拓展欧几里得算法

知识储备: 1.“|”整除号 eg:若b可被a整除,或a整除b,则可记作a|b 如2|6,8|16 性质: ①a|b,b|c =&gt; a|c ②a|b,a|c =&gt; a|(b+c)=&gt;a|(ma+mb) (m,n∈Z) ③a|b(a≠0) =&gt; |a|≤|b|2.“≡”同余号 两个整数a,b,若它们除以整数m所得的余数相等,则称a,b对于模m同余...

2017-03-18 21:44:32 361

原创 POJ 1502 MPI Maelstrom【最短路】

题目来戳呀DescriptionBIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee’

2017-03-17 21:39:12 227

转载 图论之邻接矩阵

转自这里为了表现图中顶点之间的关联,我们可以使用邻接矩阵来实现图结构。所谓的邻接矩阵,就是一个反应边与边之间联系的二维数组。这个二维数组我们用matrix[numV][numV]表示,其中numV是顶点数。 对于无权图 若顶点Vi和Vj之间有边,则matrix[Vi][Vj]=1;否则matrix[Vi][Vj]=0。 对于有权图 若顶点Vi和Vj之间有边,且权值为weight,则matri

2017-03-17 19:20:58 2675

原创 POJ 2387 Til the Cows Come Home【最短路】

题目来戳呀DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she

2017-03-16 16:43:22 238

转载 atoi函数学习

原文来戳呀 1.功能:把字符串转换成整型数。2.原型:int atoi(const char *nptr);说明: 参数nptr字符串,如果第一个非空格字符不存在或者不是数字也不是正负号则返回零,否则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。3.头文件:<stdlib.h>(但是hdu3347我用algorithm过了,没搞懂为什么)#include <st

2017-03-15 20:36:00 183

原创 HDU 3347 Calculate the expression【模拟】

题目来戳呀Problem DescriptionYou may find it’s easy to calculate the expression such as: a = 3 b = 4 c = 5 a + b + c = ? Isn’t it?InputThe first line contains an integer stands for the number of test c

2017-03-14 21:48:00 261

原创 HDU 3349 lazy gege【数学几何】

题目来戳呀Problem DescriptionGege hasn’t tidied his desk for long,now his desk is full of things. This morning Gege bought a notebook,while to find somewhise to put it troubles him. He wants to tidy a sma

2017-03-14 19:06:17 319

原创 HDU 3343 An ant's story【思维】

题目来戳呀Problem DescriptionLong long ago, there is an ant crawling on an L-meter magic rubber band with speed of v cm/s.The magic rubber band will elongate m meters every second. We can assume that...

2017-03-13 20:36:22 544

原创 HDU 2844 Coins【多重背包】

题目来戳呀 就是这个题!两道一模一样题意相仿的题目O.O把比赛的那道题做成这个了,实际上是另一道贪心!气哭呜呜呜Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3…An Silverland dollar. One day Hibix opened purse and found there were s

2017-03-13 19:51:34 302

原创 HDU 3348 coins【贪心】

题目来戳呀Problem Description“Yakexi, this is the best age!” Dong MW works hard and get high pay, he has many 1 Jiao and 5 Jiao banknotes(纸币), some day he went to a bank and changes part of his money into 1

2017-03-12 21:29:00 436

转载 贪心算法与动态规划算法的异同

今天比赛硬是把贪心做成了背包问题,气哭口亨!动态规划和贪心算法都是一种递推算法,均由局部最优解来推导全局最优解 。渊博二转但是最后树的原创很精彩贪心算法: 不断贪心地选取当前最优策略的算法设计方法。 1.贪心算法中,作出的每步贪心决策都无法改变,因为贪心策略是由上一步的最优解推导下一步的最优解,而上一部之前的最优解则不作保留。 2.由(1)中的介绍,可以知道贪心法正确的条件是:每一步的最优

2017-03-12 19:55:30 17918

原创 2016-2017 Tue&Thus Training

Mar 7th A【最小生成树】 B【多重背包】http://blog.csdn.net/ppppublic/article/details/61616560 C【并查集】http://blog.csdn.net/ppppublic/article/details/61208440 D【母函数】Mar 9th A B C D E Mar 14th Mar 16th

2017-03-12 18:57:32 165

原创 2016-2017 Training Weekly

Contest 1 Mar 5th A【贪心】【map】http://blog.csdn.net/ppppublic/article/details/60875776 B【思维】http://blog.csdn.net/ppppublic/article/details/60882614 C【思维】【pair】http://blog.csdn.net/ppppublic/article/de

2017-03-12 18:29:59 166

原创 POJ 1276 Cash Machine 【多重背包】

题目来戳呀DescriptionA Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denominat

2017-03-12 13:36:08 210

原创 HDU 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活【多重背包】

题目来戳呀Problem Description急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。 请问:你用有限的资金最多能采购多少公斤粮食呢?Input输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(1<=n<=

2017-03-11 21:38:41 242

原创 POJ 1703 Find them, Catch them【并查集】

题目来戳呀DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to i

2017-03-10 21:09:37 211

原创 POJ 1182 食物链【并查集】

题目来戳呀Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是”1 X Y”,表示X和Y是同类。 第二种说法是”2 X Y”,表示X吃Y。 此人对N个动物

2017-03-10 20:36:57 218

原创 小白的碎碎念

各路大神你们就当没看见这篇文章吧QAQ 我自己记的很小很小琐碎的点啊QAQ 求不拍QAQ定义常量 用const,最好不用define。 格式:const type name=number ex: const int maxn=0x3f3f3f3f字典序 指从前到后比较两个字符串大小的方法。首先比较第一个字符,如果不同则第1个字符较小的字符串更小,如果相同则继续比较第2个字符……如此继续,

2017-03-10 17:45:16 321

原创 HDU 1905 Pseudoprime numbers【素数】【快速幂】

题目来戳呀Problem DescriptionFermat’s theorem states that for any prime number p and for any integer a > 1, a^p == a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Som

2017-03-09 20:40:30 328

原创 HDU 6016 Count the Sheep【思维】

题目来戳呀 还不是很理解QAQProblem DescriptionAltough Skipping the class is happy, the new term still can drive luras anxious which is of course because of the tests! Luras became worried as she wanted to skip th

2017-03-08 21:17:21 303

原创 HDU 6015 Skip the Class【贪心】【map】

题目戳我呀Problem DescriptionFinally term begins. luras loves school so much as she could skip the class happily again.(wtf?)Luras will take n lessons in sequence(in another word, to have a chance ...

2017-03-08 16:56:18 600

原创 HDU 1789 Doing Homework again【贪心】

题目来戳呀Problem DescriptionIgnatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands i

2017-03-07 21:15:35 200

转载 pair函数学习

转自c++学习之pair 1.Pair类型概述 pair是一种模板类型,其中包含两个数据值,两个数据的类型可以不同,基本的定义如下:pair<int, string> a;表示a中有两个类型,第一个元素是int型的,第二个元素是string类型的,如果创建pair的时候没有对其进行初始化,则调用默认构造函数对其初始化。pair<string, string> a("James", "Joy");

2017-03-05 20:58:01 565

原创 HDU 6011 Lotus and Characters【思维】【pair】

DesciptionLotus has nn kinds of characters,each kind of characters has a value and a amount.She wants to construct a string using some of these characters.Define the value of a string is:its first char

2017-03-05 20:50:38 280

原创 【HDU神他么畅通工程系列】--TBC

HDU 1232 HDU 1233 HDU 1863 HDU 1874 HDU 1875 HDU 1879

2017-03-03 22:55:30 260

原创 图论之最短路

给定一个带权有向图 G=(V,E) ,其中每条边的权是一个非负实数。另外,还给定 V 中的一个顶点,称为源。现在我们要计算从源到所有其他各顶点的最短路径长度,即路上各边权之和。这个问题通常称为单源最短路问题。Dijkstra算法:适用于边权为正的情况。该算法同时适用于有向图和无向图。Dijkstra算法和 最小生成树Prim算法最小生成树算法非常类似,两个算法都是基于贪心算法。这里模仿MST(M

2017-03-03 21:37:16 515

原创 图论之最小生成树

在无向图中,连通且不含圈的图称为树。给定无向图G,连接G中的所有点,且边集是E的子集的树称为G的生成树,而权值最小的生成树称为最小生成树(MST)。 构造MST的算法有很多,最常见的有两个:Kruskal算法和Prim算法。 话不多说,用题来讲吧≧▽≦ SDNU 1218认路Descriptionlmh刚来到山师学习,他知道以后自己要在这里生活很长时间,所以想要尽快弄清楚学校里面...

2017-03-02 23:15:18 336

原创 图论之并查集

并查集是一种树型的数据结构,用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。常常在使用中以森林来表示。 集就是让每个元素构成一个单元素的集合,也就是按一定顺序将属于同一组的元素所在的集合合并。 并查集里的每一个组表示组内所有元素代表的情况都同时发生或不发生。 为了更好的理解什么是并查集,我要供出这篇神文了江湖上的并查集嘻嘻 简言之, 查询问题find函数就是找帮主,...

2017-03-02 17:12:28 496

原创 紫书 优先队列

紫书 优先队列 占坑+3

2017-03-01 20:50:43 216

原创 紫书 队列

紫书 队列 占坑+2

2017-03-01 20:50:09 302

原创 紫书 栈

紫书 栈 强迫症占坑+1

2017-03-01 20:49:35 262

原创 紫书 map

强迫症表示一定要占个坑先 map

2017-03-01 20:48:09 207

转载 头文件cctype的函数系列

原版找不到的二转在此 #include <cctype>的函数 c++中应该是#include <cctype> c中应该是#include <ctype.h>以下为字符函数库中常用的函数: 函数名称 返回值 isalnum() 如果参数是字母数字,即字母或数字,该函数返回true isalpha() 如果参数是字母,该函数返回true isblank() 如果参数是

2017-03-01 20:30:07 4313 1

原创 UVa 10815 Andy's First Dictionary 【set】【字典序】

UVa 10815 安迪上天想要做字典 Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is,well, not quite enough. Instead of thi

2017-03-01 20:16:11 290

空空如也

空空如也

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

TA关注的人

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