
ACM
文章平均质量分 88
Lyh-Memory
每个不曾起舞的日子都是对生命的辜负
展开
-
UVA1605-Building for UN
Building for UNTime limit: 3.000 secondsThe United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will c原创 2015-07-31 20:38:54 · 1068 阅读 · 0 评论 -
POJ 2409 - Let it Bead【Polya定理】
Let it BeadTime Limit: 1000MSMemory Limit: 65536KBDescription:"Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. As you can deduce from the company name, their b原创 2015-08-13 17:14:44 · 505 阅读 · 0 评论 -
UVA 10733 - The Colored Cubes【Polya定理】
The Colored CubesTime Limit: 3000MSMemory Limit: Unknown All 6 sides of a cube are to be coated with paint. Each side is is coated uniformly with one color. When a selection of n diffe原创 2015-08-13 16:07:09 · 472 阅读 · 0 评论 -
HDU 1817 - Necklace of Beads【Polya定理】
Necklace of BeadsTime Limit: 1000MS Memory Limit: 32768KBDescription:Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 40 ). If the repetiti原创 2015-08-07 21:24:54 · 557 阅读 · 0 评论 -
HDU 1812 - Count the Tetris【Polya定理】
Count the TetrisTime Limit: 1000MSMemory Limit: 32768KBDescription:话说就是因为这个游戏,Lele已经变成一个名人,每当他一出现在公共场合,就有无数人找他签名,挑战。 为了防止引起社会的骚动,Lele决定还是乖乖呆在家里。在家很无聊,Lele可不想像其他人一样每天没事在家数钱玩,于是他就开始数原创 2015-08-06 17:21:10 · 858 阅读 · 0 评论 -
POJ 1879 - Tempus et mobilius Time and motion【置换群】
Tempus et mobilius Time and motionTime Limit: 1000MS Memory Limit: 30000KBDescription: Tempus est mensura motus rerum mobilium. Time is the measure of movement.-- Auctoritates A原创 2015-08-05 21:23:24 · 686 阅读 · 0 评论 -
POJ 3270 - Cow Sorting【置换群】
Cow SortingTime Limit: 2000MS Memory Limit: 65536KBDescription:Farmer John's N (1 ≤ N ≤ 10,000) cows are lined up to be milked in the evening. Each cow has a unique "grumpiness" level in th原创 2015-08-05 16:46:17 · 499 阅读 · 0 评论 -
POJ 1721 - CARDS【置换群】
CARDSTime Limit: 1000MSMemory Limit: 10000KBDescription:Alice and Bob have a set of N cards labelled with numbers 1 ... N (so that no two cards have the same label) and a shuffle machine. We a原创 2015-08-05 16:03:28 · 514 阅读 · 0 评论 -
置换群的整幂运算【置换群】
置换群的整幂运算定理及结论:1.在置换群中有一个定理:设T^k = e(T 为一置换,e为单位置换(单位置换:映射函数为 f(x) = x 的置换)),那么k的最小正整数解是 T 的拆分的所有循节长度的最小公倍数.2.设 T^k = e( T 为一循环,e为单位置换),那么k的最小正整数解为 T 的长度.3.单位置换就是若干个只含单个元素的循环的并,也就是说,长原创 2015-08-03 21:28:09 · 5385 阅读 · 0 评论 -
POJ 1026 - Cipher【置换群】
CipherTime Limit: 1000MSMemory Limit: 10000KBDescription:Bob and Alice started to use a brand-new encoding scheme. Surprisingly it is not a Public Key Cryptosystem, but their encoding and deco原创 2015-08-03 17:22:06 · 472 阅读 · 0 评论 -
POJ 2369 - Permutations 【置换群】
PermutationsTime Limit: 1000MS Memory Limit: 65536KBDescription:We remind that the permutation of some final set is a one-to-one mapping of the set onto itself. Less formally, that is a wa原创 2015-08-01 16:20:38 · 425 阅读 · 0 评论 -
Eratosthenes筛选法与欧拉筛选法
Eratosthenes筛选法由于一个合数总是可以分解成若干个质数的乘积,那么如果把质数的倍数都去掉,那么剩下的就是质数了.Eratosthenes筛选法的思想特别简单:对于不超过n的每个非负整数p,删除2p,3p,4p,...,当处理完所有数之后,还没有被删除的就是素数.如果用vis[i]表示i已经被删除,则筛选法的代码可以写成:void isprime(int n)///筛选1-n原创 2015-08-14 17:40:59 · 5029 阅读 · 0 评论 -
UVA 11582 - Colossal Fibonacci Numbers!【大数幂取模】
Colossal Fibonacci Numbers!Time Limit: 1000MS Memory Limit: UnknownDescription:The i’th Fibonacci numberf (i) is recursively defined in the following way:• f (0) = 0 and f原创 2015-08-15 16:17:51 · 648 阅读 · 0 评论 -
数学模板 - 计算方法
二分查找法/* 在数组b中查找是否有数组a中的元素 */#include #include int comp(const void *a, const void *b){ return *(int *)a - *(int *)b;}int main(){ int n, m; int i, j, x, y, s, mid; int a[100010], b[100010];原创 2015-08-26 20:26:54 · 490 阅读 · 0 评论 -
数学模板 - 组合数学
排列组合生成1~n的排列:void solve(int n, int *a, int num)///solve(n,mem,0),输入n,按字典序从小到大的顺序输出前n个数的所有排列{ if(num == n)///递归边界 { for(int i = 0; i < n - 1; i++) printf("%d ",a[i]);原创 2015-08-26 16:14:41 · 690 阅读 · 0 评论 -
NBUT 1224 - Happiness Hotel【佩尔方程】
Happiness HotelTime Limit:1000MS Memory Limit:131072KBDescription:The life of Little A is good, and, he managed to get enough money to run a hotel. The best for him is that he need not g原创 2015-08-24 17:23:25 · 784 阅读 · 1 评论 -
数论模板 - 佩尔方程
佩尔方程输入一个数k,求方程ans^2 = k*n*n+1 中ans的最小整数解(n是大于等于一的整数,无上限)#include #include #include #include #include using namespace std;int can[1005] = {0};int a[10005][605]= {0};int x[6005], y[60原创 2015-08-24 17:06:42 · 734 阅读 · 0 评论 -
数学模板 - 数论基础
欧几里得(辗转相除)算法:int gcd(int a, int b) ///最大公约数{ return b == 0 ? a : gcd(b, a % b);}int lcm(int a, int b) ///最小公倍数{ if (a * b == 0) return 0; return a / gcd(a, b) * b;}扩展欧几里得算法:原创 2015-08-23 09:43:56 · 464 阅读 · 0 评论 -
模板 - 最长公共子序列
最长公共子序列#include #include #include #include using namespace std;string str;///公共子序列char s1[1000], s2[1000];int dp[1000][1000], mark[1000][1000];///数据太大,dp数组变成滚动数组int LCS(){ int i, j,原创 2015-08-21 15:36:17 · 385 阅读 · 0 评论 -
二维几何模板 - 圆和球有关计算模板
圆和球有关计算模板#include #include #include #include #include #include #include #include #include using namespace std;const double PI = acos(-1.0);struct Point{ double x, y; Point原创 2015-08-20 15:58:54 · 459 阅读 · 0 评论 -
二维几何模板 - 二维几何基础
二维几何模板struct Point{ double x, y; Point(double x = 0, double y = 0) : x(x), y(y){ }};typedef Point Vector;Vector operator + (Vector A, Vector B) {return Vector(A.x + B.x, A.y +原创 2015-08-19 16:46:56 · 489 阅读 · 0 评论 -
hdu 4709 - Herding【计算几何-三角形面积】
HerdingTime Limit:1000MS Memory Limit:32768KBDescription:Little John is herding his father's cattles. As a lazy boy, he cannot tolerate chasing the cattles all the time to avoid unnecessar原创 2015-08-19 15:29:15 · 440 阅读 · 0 评论 -
UVA 10375 - Choose and divide【唯一分解定理】
Choose and divideTime Limit: 3000MSMemory Limit: UnknownDescription:The binomial coefficient C(m, n) is defined asGiven four natural numbers p, q, r, and s, compute the the result of d原创 2015-08-15 17:03:18 · 571 阅读 · 0 评论 -
UVA120 - Stacks of Flapjacks
Stacks of FlapjacksTime limit: 3.000 seconds题意: 锅子里面有一叠煎饼,一共n张,每张煎饼标有一个数字,厨师可以选择一个数k,把从锅底数第k张上面的煎饼全部翻过来,即原来在上面的煎饼被翻到了下面!算法分析: 题目要求是对煎饼序号排序,实际是"颠倒一个连续子序列",题目可以用到选择排序思想,以从大到小的顺序依次把每个数排到正确的原创 2015-07-31 20:03:45 · 407 阅读 · 0 评论 -
UVA1152-4 Values whose Sum is 0
4 Values whose Sum is 0Time limit: 9.000 secondsThe SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how manyquadruplet (a, b, c, d )原创 2015-07-31 20:46:19 · 477 阅读 · 0 评论 -
斯特林公式 ——Stirling公式(取N阶乘近似值)
斯特灵公式是一条用来取n阶乘近似值的数学公式。一般来说,当n很大的时候,n阶乘的计算量十分大,所以斯特灵公式十分好用,而且,即使在n很小的时候,斯特灵公式的取值已经十分准确。 公式为: 这就是说,对于足够大的整数原创 2014-08-07 10:39:19 · 7825 阅读 · 0 评论 -
Vector容器的基本用法
vector作为STL提供的标准容器之一,是经常要使用的,有很重要的地位,并且使用起来也是灰常方便。vector又被称为向量,vector可以形象的描述为长度可以动态改变的数组,功能和数组较为相似。实际上更专业的描述为:vector是一个多功能的,能够操作多种数据结构和算法的模板类和函数库,vector之所以被认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单地说,vector是一个能原创 2015-07-14 10:27:28 · 1409 阅读 · 0 评论 -
马的走法
马的走法时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte描述在一个4*5的棋盘上,马的初始位置坐标(纵 横)位置由键盘输入,求马能返回初始位置的所有不同走法的总数(马走过的位置不能重复,马走“日”字)。如果马的初始位置坐标超过棋盘的边界,则输出ERROR。例如初始位置为4 6,则输出ERROR。输入原创 2014-08-14 20:34:02 · 1301 阅读 · 0 评论 -
玉树搜救行动(DFS)
玉树搜救行动时间限制(普通/Java):3000MS/10000MS 运行内存限制:65536KByte描述自从玉树受灾以来,有关部门一直在现场抢救落难的人。他们用个种方法搜救,用上了搜救犬,有了搜救犬找到生命迹象就容易了。 假设现场用一个矩阵表示,抢救的有多条搜救犬,受灾的人也有多个可能。例子:#p.d#p######.#d……..#原创 2014-08-08 10:41:34 · 2033 阅读 · 0 评论 -
Shopaholic
Shopaholic时间限制(普通/Java):3000MS/10000MS 运行内存限制:65536KByte描述Lindsay is a shopaholic. Whenever there is a discount of the kind where you can buy three items and only pay for two,原创 2014-08-14 21:04:19 · 539 阅读 · 0 评论 -
游览珠海校区
游览珠海校区时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:2 测试通过:2描述 The 1^st Annual Guangdong Collegiate Programming Contest (GDCPC) was held in Zhuhai Campus of Zh原创 2014-08-14 19:54:09 · 1163 阅读 · 0 评论 -
数据结构——集合合并
数据结构-集合合并时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte描述假设利用两个线性表LA和LB分别表示两个集合A和B(即线性表中的数据元素即为集合中的成员),现要求一个新的集合A=A∪B。这就要求对线性表做如下操作:扩大线性表LA,将存在于线性表LB中而不存在于线性表LA中的数据元素插入到线性表LA中去。只要从原创 2014-08-07 11:10:23 · 5695 阅读 · 0 评论 -
UVA1368 - DNA Consensus String
DNA Consensus StringTime limit: 3.000 secondsDNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It consists of four different nucleotides, namely Aden原创 2015-05-25 13:41:08 · 486 阅读 · 0 评论 -
循环日程表问题
循环日程表问题问题描述:设有 n = 2^k 个运动员进行网球循环赛,需要设计一个满足以下要求的比赛日程表:1.每个选手必须与其他 n-1 个选手各赛一次;2.每个选手一天只能参赛一次;3.循环赛一共进行 n-1 天;按此要求设计一张比赛日程表,该表有 n 行和n-1 列,第 i 行 j 列为第 i 个选手在第 j 天所遇到的选手。算法分析:循环日程表问原创 2015-07-23 16:01:19 · 958 阅读 · 0 评论 -
棋盘覆盖问题
有一个2^k * 2^k的方格棋盘,恰有一个方格是黑色的,其他为白色。你的任务是包含3个方格的 L 型牌覆盖所有白色方格。黑色方格不能覆盖,且任意一个白色方格不能同时被两个活更多牌覆盖。如图一所示为L 型牌的4种旋转方式。图一 L 型牌由于棋盘是2^k * 2^k的,则可用分治方法来解决该问题.先把棋盘切为4块,则一块都是2^(k-1) * 2^(k-1) ,有黑原创 2015-07-22 15:15:37 · 1117 阅读 · 0 评论 -
UVA140 - Bandwidth
BandwidthTime limit: 3.000 secondsGiven a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an ordering on the elements in V, then the bandwidth of a node v is defined原创 2015-07-20 09:54:25 · 523 阅读 · 0 评论 -
枚举排列
生成1~n的排列:输入整数n,按字典序从小到大的顺序输出前n个数的所有排列。生成1~n的排列可以通过递归思想解决!#include #include #include #include #include #include using namespace std;const int Max = 100000 + 10;int mem[Max];void solv原创 2015-07-16 09:02:06 · 881 阅读 · 0 评论 -
UVA11059 - Maximum Product
Maximum ProductTime limit: 3.000 secondsGiven a sequence of integers S = {S1, S2, . . . , Sn}, you should determine what is the value of themaximum positive product involving consecutive terms原创 2015-07-15 20:42:57 · 521 阅读 · 0 评论 -
UVA725 - 725 - Division
DivisionTime limit: 3.000 secondsWrite a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0through 9 once each, such that the first number divide原创 2015-07-15 19:52:02 · 461 阅读 · 0 评论 -
3401 - Colored Cubes
Colored CubesTime limit: 3.000 secondsThere are several colored cubes. All of them are of the same size but they may be colored differently. Eachface of these cubes has a single color.原创 2015-07-09 15:07:42 · 656 阅读 · 0 评论