08 2012 档案

回文串 poj 1159
摘要:PalindromeTime Limit: 3000MSMemory Limit: 65536KTotal Submissions: 43607Accepted: 14862DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal number 阅读全文

posted @ 2012-08-31 09:10 yumao 阅读(427) 评论(0) 推荐(0)

最长公共子序列 poj1458
摘要:Common SubsequenceTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 30423Accepted: 11856DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > 阅读全文

posted @ 2012-08-31 09:03 yumao 阅读(1281) 评论(0) 推荐(0)

vector 可变长数组 hdu 3823
摘要:Problem FTime Limit : 4000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 6 Accepted Submission(s) : 1Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionBesides the ordinary Boy Friend and Girl Friend, here we define a more academic kind of f 阅读全文

posted @ 2012-08-30 22:26 yumao 阅读(1210) 评论(0) 推荐(0)

取多次方的前n位
摘要:K次方Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 23 Accepted Submission(s) : 10Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description所有在程式设计已经有点经验的人都知道,当k很大时你无法完整的表达出n k。例如: C语言的函数 pow(123456,455)能够用double资料型态来表达,但是你却无法得到所有正确的 阅读全文

posted @ 2012-08-24 22:51 yumao 阅读(205) 评论(0) 推荐(0)

DP 记忆化搜索 poj 1088
摘要:滑雪Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 60568Accepted: 22075DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向... 阅读全文

posted @ 2012-08-23 21:43 yumao 阅读(236) 评论(0) 推荐(0)

USC newweek2 G
摘要:Problem DescriptionFor national security, the coordinate systems of public map service are all in an encryption system. This means that when you got the latitude and longitude coordinates from a GPS device, you cannot finger out the real place at a public map with that coordinates.We know an encrypt 阅读全文

posted @ 2012-08-23 17:29 yumao 阅读(162) 评论(0) 推荐(0)

USC newweek2 H hdu 3335
摘要:Problem DescriptionAs we know,the fzu AekdyCoin is famous of math,especially in the field of number theory.So,many people call him "the descendant of Chen Jingrun",which brings him a good reputation.AekdyCoin also plays an important role in the ACM_DIY group,many people always ask him ques 阅读全文

posted @ 2012-08-23 17:20 yumao 阅读(226) 评论(0) 推荐(0)

旋转卡壳
摘要:该算法一般用于求凸包上两点间的最大距离。方法一: 从任意一个顶点开始,按逆时针方向计算其他每一点到该顶点的距离。使距离为一直是递增的,直到开始递减;然后记录下这一次的最大值。 然后移动为基础的那个点,从上次中断的点开始;再重复上述步骤,直到距离又递减为止。 所有的最大值即是凸包的直径。方法二: 任意取一条边,计算每一个点到该条边的距离,直到距离开始递减;具体和方法一相似。代码实现(凸包的周长,直径:方法二)#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring> 阅读全文

posted @ 2012-08-22 21:24 yumao 阅读(243) 评论(0) 推荐(0)

图 poj 1511
摘要:Invitation CardsTime Limit: 8000MSMemory Limit: 262144KTotal Submissions: 14626Accepted: 4727DescriptionIn the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. T 阅读全文

posted @ 2012-08-22 16:46 yumao 阅读(124) 评论(0) 推荐(0)

图 poj 1985
摘要:Cow MarathonTime Limit: 2000MSMemory Limit: 30000KTotal Submissions: 2672Accepted: 1317Case Time Limit: 1000MSDescriptionAfter hearing about the epidemic of obesity in the USA, Farmer John wants his cows to get more exercise, so he has committed to create a bovine marathon for his cows to run. The m 阅读全文

posted @ 2012-08-22 16:25 yumao 阅读(299) 评论(0) 推荐(0)

GCD & LCM 一个神奇的式子
摘要:DescriptionGiven x and y (2 <= x <= 100,000, 2 <= y <= 1,000,000), you are to count the number of p and q such that:1) p and q are positive integers;2) GCD(p, q) = x;3) LCM(p, q) = y.Inputx and y, one line for each test.OutputNumber of pairs of p and q.Sample Input3 60Sample Output4这道题的精 阅读全文

posted @ 2012-08-21 22:30 yumao 阅读(2602) 评论(0) 推荐(0)

Letter Grid(动规)
摘要:Consider the following letter grid:ERATATSRAUTUThere are 7 ways to read the word TARTU from the grid:ERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUGiven a letter grid and a word, your task is to determine the number of ways the word can be read from the grid. Th 阅读全文

posted @ 2012-08-19 19:54 yumao 阅读(208) 评论(0) 推荐(0)

删数问题
摘要:给你一个N位数,从中去掉K个数字,能得到的最大的数是多少?INPUT有T测试数据,每组测试数据第一行由N和K2个整数组成(1 ≤ K < N ≤ 500 000),第二行是N位数(非0开头)。OUTPUT对每组数据输出去掉K个数字得到的最大数。SAMPLE TESTSINOUT34 219247 3123123410 44177252841943234775841贪心思想: 从头遍历k次,每次遇到不递减的数字,就将其删除掉,并结束该次循环。每次循环都如上所做。 其中如果遇到从头到尾一直都是递减的,则删除最后一个数字。代码实现:#include<iostream>#includ 阅读全文

posted @ 2012-08-19 19:40 yumao 阅读(183) 评论(0) 推荐(0)

三角形的有向面积
摘要:三角形的有向面积: Double area(double x0,double y0,double x1,double y1,double x2,double y2){ Return xo*y1+y0*x2+x1*y2-x2*y1-x0*y2-x1*y0; } 上面得到的即是顶点为A(x0,y0),B(x1,y1),C(x2,y2)的三角形的有向面积S的两倍; 如果area》0,则说明ABC三点呈现逆时针排列; 如果area=0,则ABC三点共线; 如果area《0,则说明ABC三点呈现顺时针排列。这个定理:① 计算三角形的面积。 ② 判断点是否在三角形的内部。 阅读全文

posted @ 2012-08-10 10:53 yumao 阅读(1346) 评论(0) 推荐(0)

正整数的素数表达式
摘要:一个正整数一定可以用若干个素数的幂积相乘表示。eg. N=2^3*3^2*7^0……;那么怎么求一个正整数的素数表达式:首先先求出范围内所有的素数,并存在数组中: Int m; For(int i=0;i<INF;i++){ if(isprime(i)){ Prime[m]=i; M++; } }然后,求正整数的素数表达式: Cin>>n; Int n1=n; For(int j=0;j<n;j++){If(n1==0)Break; while(n1%prime[j]==0){ p[j]++; N1/=prime[j]; } If(j>max) Max=j; } 阅读全文

posted @ 2012-08-10 10:52 yumao 阅读(301) 评论(0) 推荐(0)

关于memset,memcpy的用法
摘要:1. 最常用的还是: memset(a,0,sizeof(a)); 需要注意的是memset()一般用于字节填充,即a一般是char型; 当a为char时,可以被赋任何值。而如果a是其他的类型,那么a就只能被全部赋予0或者-1,如果是其他的值,就不能保证被全部赋予。2. 接下来时memcpy(d,s,n); 其中d为指定的复制到的地方,而s是被复制的地方,n为复制的长度。并且,复制和被复制的区域不能重合。 memcpy与strcpy比较相像,区别是strcpy只针对字符串的复制,而memcpy为内存的复制,可以复制包括字符串的其他类型,比如说:结构体等。 memcpy可以指定长度,而strcp 阅读全文

posted @ 2012-08-08 10:53 yumao 阅读(175) 评论(0) 推荐(0)

用STL查询区间长度
摘要:用STL查询区间的长度: 大于等于a的第一个元素下标d 为STL中a的lower_bound值,如果所有的元素都小于a,则d=n,为把不存在的元素看成无穷大。 小于等于b的最后一个元素的下一个下标r 为b的upper_bound值,如果所有的元素都大于b,则r=0。求集合v中区间[a,b]的长度:eg. #include<algorithm> Sort(v,v+n); Int times=upper_bound(v,v+n,b)—lower_bound(v,v+n,a); 阅读全文

posted @ 2012-08-08 10:53 yumao 阅读(165) 评论(0) 推荐(0)

导航