- 博客(56)
- 收藏
- 关注
原创 树型DP 父子兄弟结构 poj 2342 Anniversary party
#include <iostream>#include <cstdio>#include <cstring>struct Tree{ int father; int child; int brother; int NOT; int s; int Max(){ return ...
2011-09-08 11:36:13
214
完全背包 poj 2063 Investment
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int c[20];int I[20];int dp[50050];int main(){ int rest,capital,t,year,bnum; scanf(...
2011-09-06 09:06:35
105
原创 快速幂取模
lld exp_mod(lld a,lld b,lld c){ lld ans=1; lld temp=a%c; if(b==0) return 1; while(b) { if(b&1) ans=ans*temp%c; temp=temp*temp%c; b>>=...
2011-08-21 22:48:32
114
原创 数位dp_HDOJ_3555_bomb
BombTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 876 Accepted Submission(s): 319Problem DescriptionThe counter-terrorists...
2011-08-19 22:05:08
102
位运算
统计1的个数int count(int x){ int res=0; while(x){ res++; x&=x-1; } return res;}
2011-08-15 10:40:42
79
原创 DP基础之LCS
#include <iostream>#include <string>using namespace std;int dp[1050][1050];int main(){ string a,b; while(cin>>a>>b) { memset(dp,0,sizeof(dp));...
2011-08-14 21:53:08
85
原创 编辑距离
编辑距离;来自wiki的编辑距离介绍编辑距离,又称Levenshtein距离,是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。例如将kitten一字转成sitting:sitten (k→s)sittin (e→i)sitting (→g)俄罗斯科学家Vladim...
2011-08-05 18:20:38
59
原创 我的进度
代码能力:50+;动态规划:数位dp:HDOJ 3555 bomb 简单数位dp:http://acm.hdu.edu.cn/showproblem.php?pid=3555dp中的双向问题:2编辑距离:1;LIS类问题;2;POJ 1887 Testing the CATCHER http://poj.org/problem?id=1887POJ 2533 L...
2011-08-01 21:16:33
110
原创 poj 2478 Farey Sequence
Farey SequenceTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7298Accepted: 2724<br />DescriptionThe Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) =
2011-04-16 16:43:00
641
原创 Uva-11549 - Calculator Conundrum
<br />11549 - CalculatorConundrum<br />Time limit: 6.000seconds <br />Problem C CALCULATOR CONUNDRUM<br />Alice got a hold of an old calculator that can display ndigits. She was bored enough to come up with the following time waster. <br />She enters
2011-03-14 23:18:00
784
1
原创 线性时间选择
<br />今天学习了线性时间选择,主要是通过快排的方法,在一个平均时间线性的情况下进行第k小元素的选择,结合一道题目进行描述;<br />题目来自算法设计与分析就是王晓东的那本;<br />算法实现题2-1 输油管道问题<br />«问题描述:<br />某石油公司计划建造一条由东向西的主输油管道。该管道要穿过一个有n 口油井的油<br />田。从每口油井都要有一条输油管道沿最短路经(或南或北)与主管道相连。如果给定n口油<br />井的位置,即它们的x 坐标(东西向)和y 坐标(南北向)
2011-02-27 15:38:00
7710
原创 检查金币
检查金币Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB Total submit users: 27, Accepted users: 20 Problem 10038 : No special judgementProblem description ACM公司生产金币的设备出了问题,使得最近生产的10批金币的重量出现了波动:本来金币的标准重量是10克,但现在有的可能是11克,有的可能9克,也有可
2011-01-21 18:44:00
1317
1
原创 UVa 11538 - Chess Queen
<br />Problem A<br />Chess Queen <br />Input: Standard Input<br />Output: StandardOutput <br /> <br />You probably know how the game ofchess is played and how chess queen operates. Two chess queens are in attackingposition when they are on same row
2010-12-20 17:17:00
776
原创 Hdu_1004_Let the Balloon Rise
Let the Balloon Rise<br />Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 26274 Accepted Submission(s): 8164<br /><br />Problem DescriptionContest time again! How excited it is to see bal
2010-11-15 19:20:00
551
原创 PKU 3278 Catch That Cow
Catch That CowTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 19245Accepted: 5931<br />Description<br />Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤
2010-10-25 21:54:00
1392
原创 HDU 1003 maxsum
Max Sum<br />Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 43995 Accepted Submission(s): 9659<br /><br />Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to cal
2010-10-11 11:17:00
548
原创 强大的线性时间筛法
<br />输入n,求n以内的所有素数<br />算法用两个数组存储数据:<br />一个是prime[],存储n以内所有的素数,其index为pi,初值为0<br />一个是is_prime[i],表示自然数i(i<=n)是不是质数。<br />算法如下:<br />linear_prime_sieves<br />1: set is_prime[] to true<br />2: for i=2 to n<br />3: if is_prime[i]=true then prime[pi++]
2010-10-05 10:48:00
397
原创 转载自USACO的训练指导
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and made an amazing discovery: there are only 16 types of programming contest problems! Furthermore, the top several comprise almost 80% of the problems seen at
2010-10-05 09:22:00
720
原创 USACO your ride is here我的第一题~主要是为了联系一下文件输入输出
Your Ride Is HereIt is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let t
2010-10-05 09:19:00
2863
原创 pku 1922 Ride to School
#include #include #include using namespace std;struct rider{ float speed; float time;}r[10005];bool cmp(rider a,rider b){ return a.time}int main(){ int n; int i,j; while(cin>>n,n) { for(i=0;i { cin>>r[i].speed>>r[i].time;
2010-09-11 17:03:00
539
原创 pku 1565 Skew Binary
Skew BinaryTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7902 Accepted: 5043<br />DescriptionWhen a number is expressed in decimal, the kth digit represents a multiple of 10k. (Digits are numbered from right to left, where the least significant
2010-09-11 15:54:00
389
原创 PKU 1552 Doubles
DoublesTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 13322 Accepted: 7445<br />DescriptionAs part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to de
2010-09-11 15:39:00
333
原创 PKU_2000_Gold Coins
Gold CoinsTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 14149 Accepted: 8866<br />DescriptionThe king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two days (the sec
2010-09-11 15:10:00
348
原创 PKU 3438 look and say
Look and SayTime Limit: 5000MSMemory Limit: 65536KTotal Submissions: 6241Accepted: 3776<br />DescriptionThe look and say sequence is defined as follows. Start with any string of digits as the first element in the sequence. Each subsequent eleme
2010-08-17 17:21:00
755
2
原创 PKU 3663 Costume Party
<br />排序题目,水过~Costume PartyTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 6306Accepted: 2423<br />Description<br />It's Halloween! Farmer John is taking the cows to a costume party, but unfortunately he only has one costume. The costu
2010-08-17 17:02:00
878
原创 很有用的小数化为分数算法!小学生的~
<br />在小学生的奥赛网上看到了,小数化分数的算法(其实就是解法,写程序多了,觉得能解决问题的办法都叫算法……),很好很强大啊!拿来分享给大家。<br />唉……像当年哥也学过奥赛呢,呵呵~远了~第十二讲 循环小数化分数<br />来源:www.jiajiao100.com 文章作者:Dfss 2004-04-19 10:30:00<br /><br /> <br />一、纯循环小数化分数<br /> 从小数点后面第一位就循环的小数叫做纯循环小数。怎样把它化为分数呢?看下面例题。<br />例1
2010-08-17 16:28:00
2073
原创 byvoid 神牛的tarjan算法讲解!
[有向图强连通分量]在有向图G中,如果两个顶点间至少存在一条路径,称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。非强连通图有向图的极大强连通子图,称为强连通分量(strongly connected components)。下图中,子图{1,2,3,4}为一个强连通分量,因为顶点1,2,3,4两两可达。{5},{6}也分别是两个强连通分量。直接根据定义,用双向遍历取交集的方法求强连通分量,时间复杂度为O(N^2+M)。更好的方法是
2010-08-14 17:12:00
2978
1
原创 PKU 2485 Highways
HighwaysTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 9544Accepted: 4482<br />DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The
2010-08-14 16:52:00
497
原创 PKU 3210 Coins
n个硬币<br />如果是偶数的话:肯定可以分成两个奇数相加,这样翻的话肯定会翻奇数次;也肯定可以分成两个偶数相加,这样翻的话就肯定是偶数次;这样就<br />肯定没有一个值同时满足的;所以偶数就不成立;<br />如果是奇数的话:就肯定是分成一个奇数和一个偶数相加;如果全部只翻奇数的情况,那么n次就可以满足所有的,如果全部翻偶数的情况,那么<br />n-1次就可以满足所有的。<br />所有最后答案就是n-1;<br />#include <iostream>using name
2010-08-13 16:21:00
353
原创 PKU 1504 Adding Reversed Numbers
Adding Reversed NumbersTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 9491Accepted: 5250<br />DescriptionThe Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Theref
2010-08-11 11:03:00
644
原创 PKU 2521 How much did the businessman lose这道题太水了………………
How much did the businessman loseTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7880Accepted: 5272<br />DescriptionBusinessmen, of course, can make much money. However, sometimes, they would lose money in trading. For example, Jame, a
2010-08-09 16:25:00
515
原创 PKU 1936 All in All
All in AllTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 16864Accepted: 6633<br />DescriptionYou have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a cleve
2010-08-08 16:53:00
323
原创 PKU 1007 DNA Sorting
DNA SortingTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 47618Accepted: 18598<br />DescriptionOne measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For insta
2010-08-08 10:52:00
308
原创 next_permutation解决排列问题的利器
<br />今天看到了STL中的next_permutation函数,其功能之强大令人拜倒,next_permutation的功能是在全排列中查找下一个排列,函数原型及源码就不说了,这里举一个应用的例子排列Time Limit: 1000MSMemory Limit: 30000KTotal Submissions: 8579Accepted: 3832<br />Description题目描述:<br /> 大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列
2010-08-08 10:08:00
383
原创 kruskal算法
Dark roadsTime Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB Total submit users: 15, Accepted users: 15 Problem 10648 : No special judgementProblem description Economic times these days are tough, even in Byteland. To reduce t
2010-08-07 16:12:00
391
原创 优先队列三题
<br /> 优先队列是一种十分强大的数据结构,它保持了一种动态的有序性,对于不断改变有入队的操作,而又需要某种最大或最小的操作的问题是再合适不过了,通常优先队列的实现是由最小堆或者最大堆完成的,并通过堆排序保持队列的有序性,模拟队列的结构,在实际比赛中要写一个堆排序还是要一定的时间的,但是stl中queue容器中已经可以实现优先队列,下面以三道基本的题目来演示priority_queue的作用。聪明的木匠Time Limit: 1000ms, Special Time Limit:250
2010-08-07 15:38:00
1384
原创 PKU 1477 Box of Bricks
Box of BricksTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 9698Accepted: 4233<br />DescriptionLittle Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. "Look, I've bui
2010-08-06 16:01:00
683
原创 博弈论经典问题Nim问题
<br /> <br />博弈论经典问题,Nim游戏是一个典型的组合游戏问题,很多游戏问题都可以规约到Nim游戏问题。Nim游戏问题是一个ICG(Impartial Combinatorial Games)问题;<br />ICG问题的特征是:<br />1.两个人参与,交替走棋;<br />2.可能的走法在一个有限的集合里选取;<br />3.游戏局面无后效性,未来与过去无关;<br />4.如果某选手无法走动,则判负;<br />Nim的理论<br />游戏状态只分两种:当前先手必胜,当前先手必败;前者
2010-08-06 15:40:00
5376
原创 PKU 3176 Cow Bowling
Cow BowlingTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7037Accepted: 4582<br />DescriptionThe cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standar
2010-08-03 16:30:00
529
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人