自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 快排(分治法)

void qsort(int s[], int l, int r){ int i, j, x; if (l < r) { i = l; j = r; x = s[i]; while (i < j) { while(i x) j--; /* 从右向左找第一个小于x的数

2014-01-24 16:34:18 825

原创 poj——3664——Election Time

DescriptionThe cows are having their first election after overthrowing the tyrannical Farmer John, and Bessie is one of N cows (1 ≤ N ≤ 50,000) running for President. Before the election actually

2014-01-24 16:31:33 884

原创 poi(拓扑排序)

给出一个图的结构,输出其拓扑排序序列,要求在同等条件下,编号小的顶点在前输入若干行整数,第一行有2个数,分别为顶点数v和弧数a,接下来有a行,每一行有2个数,分别是该条弧所关联的两个顶点编号输出若干个空格隔开的顶点构成的序列(用小写字母)样例输入6 81 21 31 43 23 54 56 46 5样例输出v1 v3 v2 v6 v4 v

2014-01-23 21:05:04 1120

原创 hdu——1285——确定比赛名次(拓扑)

Problem Description有N个比赛队(1 Input输入有若干组,每组中的第一行为二个数N(1 Output给出一个符合要求的排名。输出时队伍号之间有空格,最后一名后面没有空格。其他说明:符合条件的排名可能不是唯一的,此时要求输出时编号小的队伍在前;输入数据保证是正确的,即输入数据确保一定能有一个符合要求的排名。

2014-01-23 19:07:32 467

原创 poj——1094——Sorting It All Out(拓扑排序)

DescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For example, the sorted sequenc

2014-01-23 15:59:54 651

原创 poj——1789——Truck History

DescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing ea

2014-01-22 20:36:13 491

原创 朱刘算法——最小树形图

#include#include#include#include#includeusing namespace std;#define MAXN 110#define INF 1000000000#define clr(a,b); memset(a,b,sizeof(a));struct Node{ double x; double y;}node[MAXN]

2014-01-22 16:58:26 587

原创 poj——1847——Tram

DescriptionTram network in Zagreb consists of a number of intersections and rails connecting some of them. In every intersection there is a switch pointing to the one of the rails going out of the

2014-01-21 16:23:18 634

原创 poj——2457——Part Acquisition

DescriptionThe cows have been sent on a mission through space to acquire a new milking machine for their barn. They are flying through a cluster of stars containing N (1 The cows have determin

2014-01-21 13:42:16 725

原创 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

2014-01-21 10:17:44 528

原创 poj——2231——Moo Volume

DescriptionFarmer John has received a noise complaint from his neighbor, Farmer Bob, stating that his cows are making too much noise. FJ's N cows (1 <= N <= 10,000) all graze at various locati

2014-01-20 16:14:34 967

原创 poj——1664——放苹果

Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。Input第一行是测试数据的数目t(0 Output对输入的每组数据M和N,用一行输出相应的K。Sample Input17 3Sample Output8分析:本题目可使用递归方法求解。向n个盘

2014-01-20 15:18:12 620

原创 poj——1160——Post Office

题目:用数轴描述一条高速公路,有V个村庄,每一个村庄坐落在数轴的某个点上,需要选择P个村庄在其中建立邮局,要求每个村庄到最近邮局的距离和最小。分析:经典DP1、考虑在V个村庄中只建立一个邮局的情况,显然可以知道,将邮局建立在中间的那个村庄即可。也就是在a到b间建立一个邮局,若使消耗最小,则应该将邮局建立在(a+b)/2这个村庄上(可以通过画图知道)。2、下面考虑建立多个邮局的问题,可以

2014-01-20 14:40:00 1392

原创 poj——1125——Stockbroker Grapevine

DescriptionStockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge

2014-01-20 11:11:32 571

原创 算法入门之正整数排序

给定一个正整数,用最少的操作次序把序列1,2.....n中的所有数变成0,每次操作可从序列中选择一个或多个整数,同时减去一个相同的正整数,n分析:1,2,3,可以把2和3同时减去2,得到1,0,1            1,2,3,4,5,6可以把4,5,6同时减去4,得到0,1,2,也就是说把min(4,5,6)等价于1,2,3,换句话说,f(6)= f(3)+1#include

2014-01-20 09:38:43 925

原创 算法入门之蚂蚁

一根长度为L厘米的木棍上有n个蚂蚁,每个蚂蚁要么朝左爬,要么朝右爬,速度为1厘米/秒,当两只蚂蚁相撞时,二者同时掉头,给出每只蚂蚁的初始位置和朝向,计算T秒之后每只蚂蚁的位置每组数据的第一行输入L,T,n,其中x表示蚂蚁距离木棍的距离,字母表示初始朝向,若T秒之前已经掉下木棍的蚂蚁输出Fell off(turning表示正在碰撞)#include #include #inclu

2014-01-19 21:28:11 1270

原创 算法入门之移动雕塑

在周长为10000的圆上等距分布着n的雕塑,现在有m个雕塑加入,希望n+m个雕塑在圆周上均匀分布,要求移动的总距离尽量少#include #include #include #include #include #include using namespace std;const int M=10005;int main(){ int n,m; while(scanf("%

2014-01-19 19:51:05 795

原创 算法入门之分金币(求极值)

圆桌旁边有n个人,每个人有一定数量的金币,每个人可以给他左右相邻的人一些金币,最终使每个人的金币数量相等,求出被转手的金币的最小数量#include #include #include #include const int M=1000005;using namespace std;int main(){ int n; long long a[M],c[M]; while(

2014-01-19 17:08:12 799

原创 算法入门之突击战(贪心)

有n个部下,每个部下需要完成一项任务,第i个部下需要花费j分钟交代任务,然后会花k分钟完成任务,需要输出完成任务的最短时间#include #include #include using namespace std;struct node{ int j; int k;}Node[10007];int cmp(node a,node b){ //if(a.k>b.k) r

2014-01-19 16:41:31 1560

原创 算法设计之勇士都恶龙

有n个头的恶龙,需要雇佣一些骑士把他杀死,有m个骑士可以雇佣,一个能力值为x的骑士可以砍掉恶龙一个直径不超过x的头,且需要支付x个金币,如果雇佣骑士才能砍掉恶龙的所有头,问:需要支付的最少金币是多少?#include #include #include const int N=20005;using namespace std;int main(){ int n;//恶龙的个数

2014-01-19 10:23:52 670

空空如也

空空如也

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

TA关注的人

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