自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(82)
  • 资源 (4)
  • 收藏
  • 关注

原创 POJ2243 Knight Moves

题目链接:http://poj.org/problem?id=2243#include #include int knight[64][64];void Floyed(){ int i,j,k,x,y; for(i=0;i<64;++i) { for(j=0;j<64;++j) {//棋盘两格之间的相对位置 x=abs(i/8-j/8); y=

2013-09-28 16:31:51 534

原创 hdu1395 2^x mod n = 1

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1395#include int main(){ int n,i,x; while(scanf("%d",&n)!=EOF) { if((n&1)==0) { printf("2^? mod %d = 1\n",n); continue; } x=1

2013-09-25 19:06:09 578

原创 hdu4524 郑厂长系列故事——逃离迷宫

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4524题解:到最后所有箱子数字都为0,从左边开始点;#include int Scan() { char ch; int ret=0;

2013-09-24 21:53:46 607

原创 hdu4520 小Q系列故事——最佳裁判

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4520#include #include #define MAXN 22int main(){ int n,i,index; double sum,minnum,maxnum; double arr[MAXN]; while(scanf("%d",&n)&&n) {

2013-09-24 21:27:27 633

原创 hdu4496 D-City

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4496题解:删除一条边,求剩余连通分量的个数,从后往前,初始状态ans[m-1]=n,每加一条边,判断两顶点是否属于同一个连通分量.是连通分量少一个,不是连通分量个数不变。#include #include #define MAXN 10002int fat

2013-09-23 21:48:19 541

原创 hdu1273 漫步森林

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1273题解:设森林里有N块空地,任意两块空地之间都有一条小径相通,与每块空地相连的路径数为n-1;每经过一块空地(一进一出)经过两条路径,所以答案为(n-1)/2.#include int main(){ int n; while(scanf("%d",&n)&&n

2013-09-22 20:58:23 973

原创 hdu1266 Reverse Number

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1266#include int main(){ int test,n,i,flag,pos,index; int arr[33]; scanf("%d",&test); while(test--) { flag=0;//标记n是否为负数 scanf("%d

2013-09-22 20:35:28 699

原创 hdu4548 美素数

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4548#include #include #define MAXN 1000000 #define SIZE 1000002 int prime[SIZE],valid[SIZE],ans[SIZE]; void getPrime()//素数筛选O(N) {

2013-09-22 19:11:30 681

原创 hdu4506 小明系列故事——师兄帮帮忙 (快速幂)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4506#include #define MOD 1000000007_int64 arr[10001];_int64 pow_mod(_int64 x,int k){//快速幂x^k%mod _int64 temp=1; while(k) { if(k&1)

2013-09-22 16:26:14 724

原创 hdu4505 小Q系列故事——电梯里的爱情

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4505#include #include #define MAXN 101int main(){ int n,Max,cnt,i,x,test; int height[MAXN]; scanf("%d",&test); while(test--) { scanf(

2013-09-22 15:43:25 953

原创 hdu4722 Good Numbers (数位DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722#include #include _int64 dp[20][10];int digits[20];_int64 DFS(int pos,int mod,int limit){ int end,i,nmode; _int64 sum=0; if

2013-09-22 14:26:59 653

原创 hdu3652 B-number (数位DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3652/*dp[len][mod][status]len表示当前位数,mod表示当前的总余数(从高位开始算)status=0:从最高位到i为没有出现13;status=1:没有出现13,第i为为1;status=2:出现13;*/#include #include

2013-09-22 10:48:55 607

原创 hdu2089 不要62 (数位DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089#include #include int dp[10][3],digits[10];void Init(){ int i; dp[0][0]=1; dp[0][1]=dp[0][2]=0; for(i=1;i<10;++i) { dp[i][0]

2013-09-21 22:34:44 651

原创 hdu3555 Bomb (数位DP)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555题解://http://www.cnblogs.com/luyi0619/archive/2011/04/29/2033117.htmldp[len][0] 代表长度为len不含49的方案数dp[len][1] 代表长度为len不含49但是以9开头的数字的方案数dp[len

2013-09-21 18:26:55 619

原创 hdu4730 We Love MOE Girls

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4730#include #include int main(){ int i,test,len,flag,cases=1; char str[110],s[8]={'n','a','n','o','d','e','s','u'}; scanf("%d",&test); w

2013-09-20 21:02:05 835

原创 hdu4707 Pet (BFS)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4707#include #include #include #define MAXN 100001using namespace std;vector mp[MAXN];int deep[MAXN*10],Que[MAXN];int Scan()

2013-09-20 19:53:43 659

原创 hdu4727 The Number Off of FFF

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727#include #define MAXN 100001int arr[MAXN];int main(){ int i,n,test,index,cases=1; scanf("%d",&test); while(test--) { scanf("%d",&

2013-09-20 17:11:49 579

原创 hdu3549 Flow Problem (Dinic)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3549#include #include #define INF 0x3f3f3f3f#define MAX_VER 20#define MAX_EDGE 2002struct node{ int to,cap,next;}edge[MAX_EDGE];int he

2013-09-15 18:56:43 543

原创 hdu1532 Drainage Ditches (Dinic)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1532题解:模版题。#include #include #define INF 0x7fffffff#define MAXN 202struct node{ int to,cap,next;}edge[MAXN<<1];int head[MAXN],lev

2013-09-15 18:06:10 568

原创 POJ2186 Popular Cows (Tarjan)

题目链接:http://poj.org/problem?id=2186题解:强连通分量缩点,Your task is to compute the number of cows that are considered popular by every other cow.只需计算出度为0的点数,如果出度为0的点数大于一,输出0(不符合题意),否则输出出度为0的强连通分量的点数。

2013-09-14 18:49:51 499

原创 POJ2553 The Bottom of a Graph (Tarjan)

题目链接:http://poj.org/problem?id=2553题解:A node v in a graph G=(V,E) is called a sink, if for every node w in G that is reachable from v, v is also reachable from w. The bottom of a graph is the su

2013-09-14 12:23:14 590

原创 POJ1236 Network of Schools (Tarjan)

题目链接:http://poj.org/problem?id=1236题解:Subtask A:强连通分量任意点可达,将强连通缩成一个点,变成有向无环图,求入度为0的点数;Subtask B:要使图成为强连通图,每个点至少要有一个入度和一个出度,一条边可以提供一个入度和一个出度,统计以上无环图没有入度顶点数和没有出度顶点数,从没有出度顶点连一条边到没有入度顶点,边添加的数量为noI

2013-09-13 21:28:55 495

转载 双连通分量

[点连通度与边连通度]     在一个无向连通图中,如果有一个顶点集合,删除这个顶点集合,以及这个集合中所有顶点相关联的边以后,原图变成多个连通块,就称这个点集为割点集合。一个图的点连通度的定义为,最小割点集合中的顶点数。       类似的,如果有一个边集合,删除这个边集合以后,原图变成多个连通块,就称这个点集为割边集合。一个图的边连通度的定义为,最小割边集合中的

2013-09-12 11:01:50 650

原创 hdu3639 Hawk-and-Chicken (Tarjan)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3639题解:将强连通分量缩成一个点,反向建图,对每个入度为0的点DFS,找出最大值即可。#include #include #include #define MAXN 5001 using namespace std;struct node

2013-09-12 10:34:53 1022

原创 hdu3072 Intelligence System (Tarjan)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3072题解:一个强连通图里 inform,cost忽略,求强连通图之间的最小cost.#include #include #define INF 0x3f3f3f3f#define MAXN 50001 struct node {

2013-09-11 22:59:10 1125

原创 hdu1827 Summer Holiday (Tarjan)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1827题解:先求出强连通图,如果强连通图i和强连通图j有一条边相连,只要打给一个强连通图其中的一个人就可以,所以求强连通图入度为0的个数即可.#include #include #define MAXN 1001 struct node {

2013-09-11 20:24:55 730

原创 hdu3836 Equivalent Sets (至少加几条边让整个图变成强连通&hdu2767)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3836题解:将强连通子图缩成一个点(强连通图俩俩可达),使图成为无环图。要使图成为强连通图,每个点至少要有一个入度和一个出度,一条边可以提供一个入度和一个出度,统计以上无环图没有入度顶点数和没有出度顶点数,从没有出度顶点连一条边到没有入度顶点,边添加的数量为noIndegree和no

2013-09-11 19:20:42 737

原创 hdu1326 Box of Bricks

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1326#include int main(){ int height[52],n,sum,avg,i,cases=1; while(scanf("%d",&n)&&n) { sum=0; for(i=0;i<n;++i) { scanf("%d",&height

2013-09-11 16:20:20 632

原创 hdu3861 The King’s Problem (强连通缩点+最小路径覆盖)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3861/*题解:state划分规则:至少存在一条路径可以从city u到city v,也存在一条路径可以从city v到city u,则u,v必须分在一个state(强连通子图必须分在一个state).一个state内u,v至少一方能够到达对方,一个只能分在一个state.(最小路径

2013-09-11 15:23:29 809

原创 hdu1269 迷宫城堡 (强连通分量Tarjan算法)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1269题解:对于任意的i和j,至少存在一条路径可以从房间i到房间j,也存在一条路径可以从房间j到房间i。求强连通分量==1?#include #include #define MAXN 10001struct node{ int from,to,next;}edge

2013-09-11 09:25:19 837

转载 强连通分量Tarjan算法

说到以Tarjan命名的算法,我们经常提到的有3个,其中就包括本文所介绍的求强连通分量的Tarjan算法。而提出此算法的普林斯顿大学的Robert E Tarjan教授也是1986年的图灵奖获得者(具体原因请看本博“历届图灵奖得主”一文)。       首先明确几个概念。强连通图。在一个强连通图中,任意两个点都通过一定路径互相连通。比如图一是一个强连通图,而图二不是。因为没

2013-09-10 21:08:43 1171

原创 hdu3605 Escape (多重匹配)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3605题解:多重匹配即 X 集合上的点对应 Y 集合上多个点 而 Y 集合上的点对应 X 中的一个点。#include #include #define MAXN 100001int mp[MAXN][11],visited[11];int capacity[11],n

2013-09-10 12:52:13 762

原创 hdu2813 One fihgt one (KM最小权值和)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2813题解:KM模版题#include #include #include #define INF 0x3f3f3f3f #define MAXN 201 int w[MAXN][MAXN],match[MA

2013-09-10 08:38:50 563

原创 hdu3395 Special Fish (KM)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3395题解:每只鱼最多只能攻击和被攻击一次,可能交配的鱼连一条边。#include #include #include #define INF 0x3f3f3f3f #define MAXN 101 int w[MAXN][MA

2013-09-09 23:00:02 702

原创 hdu2853 Assignment (KM最少改动边)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2853题解:把每条边的权值扩大k倍(k>n),然后属于原始任务的边权值+1,权值加1是为了当两条边权值相同时,更优先选择属于原始任务的边。假如原任务的h条边被选入了最优匹配中,最优权值就是k倍的最大权值+k(原计划的每条边都+1)。假如原计划的边全部在匹配中,只会增加n,又n 所以除以k后不

2013-09-09 20:21:32 609

原创 hdu4715 Difference Between Primes

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4715#include #include #define MAXN 1010000 #define SIZE 1010002 int prime[SIZE],valid[SIZE]; void getPrime()//素数筛选O(N) { int i,j,

2013-09-09 14:17:53 685

原创 hdu2426 Interesting Housing Problem (KM邻接表)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2426题解:最大权值单边(nx的每一个点都在匹配中)完备匹配,不能把学生安排在rate小于0的房间,负权边舍弃。#include #include #define INF 0x3f3f3f3f #define MAXN 502 int w[MAXN

2013-09-09 07:49:22 648

原创 hdu3435 A new Graph Game (KM)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3435题解:见http://blog.csdn.net/lezg_bkbj/article/details/11395005#include #include #include #define INF 0x3f3f3f3f

2013-09-08 21:05:36 660

原创 hdu3488 Tour (KM最小权值和)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3488题解:对于环上的每个点,入度=出度=1,将每个点拆成入点和出点,相当于左边n个城市,右边n个城市,求最优匹配。由最优匹配的性质得,每个点都会在匹配中。相当于一个点出现两次,即一次入度,一次出度。#include #include #include

2013-09-08 20:28:58 776

原创 hdu3722 Card Game (KM)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3722题解:将字符串分成X和Y集合(每个集合都是这n个节点),对于i和j这两个节点,他们的权值weight[i][j]就是将字符串s[i]拼接在字符串s[j]后面所得的值,这样建立起带权值的二分图之后,然后就是利用KM算法求解该二分图的最大权匹配.#include

2013-09-08 19:05:33 609

仿WIN8磁帖效果的ImageView

一个仿WIN8磁帖效果的ImageView

2014-07-29

Android例子源码使用ActionBar的高仿微信主界面设计

Android例子源码使用ActionBar的高仿微信主界面设计.

2014-07-29

操作系统实验 线程同步机制

实现Nachos的同步机制:锁和条件变量,并利用这些同步机制实现几个基础工具类

2013-07-13

计算机端口TCPIP详细介绍

TCPIP...............................................................................................

2011-04-16

空空如也

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

TA关注的人

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