上一页 1 ··· 259 260 261 262 263 264 265 266 267 ··· 300 下一页
2013年8月2日

HDU 4414 Finding crosses (DFS + BFS)

摘要: 题意:在N*N的图中,找出孤立存在的十字架的个数。十字架要求为正十字,孤立表示组成十字架的‘#的周围的一格再无’#‘。dfs找出在中心的‘#’(周围四格也为‘#'),则缩小了搜索范围,再bfs找出是否是符合要求。#include #include #include #include #include using namespace std;char map[55][55];int n,cnt,head,tail,vis[55][55],center[55][55];int dirx[4] = {1,-1,0,0};int diry[4] = {0,0,1,-1};struct Queu 阅读全文
posted @ 2013-08-02 22:38 you Richer 阅读(168) 评论(0) 推荐(0) 编辑

对javabean的内省操作

摘要: import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map;import org.apache.commons.beanutils.BeanUtils; import 阅读全文
posted @ 2013-08-02 22:36 you Richer 阅读(152) 评论(0) 推荐(0) 编辑

容斥原理应用(求1~r中有多少个数与n互素)

摘要: 问题:求1~r中有多少个数与n互素。 对于这个问题由容斥原理,我们有3种写法,其实效率差不多。分别是:dfs,队列数组,位运算。 先说说位运算吧:用二进制1,0来表示第几个素因子是否被用到,如m=3,三个因子是2,3,5,则i=3时二进制是011,表示第2、3个因子被用到 LL Solve(LL n,LL r){ vector p; for(LL i=2; i*i1) p.push_back(n); LL ans=0; for(LL msk=1; msk1) p.push_back(n);}void dfs(LL k,LL t,LL s,LL... 阅读全文
posted @ 2013-08-02 22:34 you Richer 阅读(310) 评论(0) 推荐(0) 编辑

hdu1026 Ignatius and the Princess I (优先队列 BFS)

摘要: Problem Description The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has to rescue our pretty Princess. Now he gets into feng5166's castle. The castle is a large labyrinth. To make the problem simply, we assume the labyrinth is a N*M two-dimensional array which left-to 阅读全文
posted @ 2013-08-02 22:32 you Richer 阅读(143) 评论(0) 推荐(0) 编辑

UVA 465 (13.08.02)

摘要: OverflowWrite a program that reads an expression consisting of twonon-negative integer and an operator. Determine if either integer orthe result of the expression is too large to be represented as a``normal'' signed integer (typeinteger if you are workingPascal, type int if you are working i 阅读全文
posted @ 2013-08-02 22:30 you Richer 阅读(195) 评论(0) 推荐(0) 编辑

1242Rescue (优先队列BFS)

摘要: Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M #include#includeusing namespace std;typedef struct nn{ int x,y; int time; friend bool operator Q; node q,p; q.time=0;q.x=sj;q.y=si; Q.push(q); while(!Q... 阅读全文
posted @ 2013-08-02 22:28 you Richer 阅读(211) 评论(0) 推荐(0) 编辑

UVA 10494 (13.08.02)

摘要: 点此连接到UVA10494思路: 采取一种, 边取余边取整的方法, 让这题变的简单许多~ AC代码:#include#includeint main() { long long mod; long long k, tmp; int len; int ans[10010]; char num[10010], ch[2]; while(scanf("%s%s%lld", num, ch, &mod) != EOF) { len = strlen(num); k = 0; tmp = 0; memset(ans, 0, sizeof(ans)); for(int i = 阅读全文
posted @ 2013-08-02 22:26 you Richer 阅读(123) 评论(0) 推荐(0) 编辑

poj - 2195 - Going Home

摘要: 题意:有n个人,n个房子,一个人每走一步(可上、下、左、右取一个方向)花费1美元,问让这n个人走到n个房子里最少需要多少美元(n >在学最小费用最大流,找模版题找到了这道。建图:1到n为人的编号,n+1到2*n为房子的编号,另加上源点0和汇点2*n+1;源点到每个人各建立一条容量为1的流,费用为0;每个人到每个房子各建立一条容量为1的流,费用按题意计算;(注意:反向费用!!!)每个房子到汇点建立一条容量为1的流,费用为0。当满足最大流时,一定是源点发出n,每个人接收1并发出1到一个房子,n个房子各发出1汇成n到汇点,所以,真是最小费用最大流的模版题。#include #include # 阅读全文
posted @ 2013-08-02 22:24 you Richer 阅读(259) 评论(0) 推荐(0) 编辑

system2之:4-LVM逻辑卷管理

摘要: LVM有扩容功能,无容错功能 物理卷: [root@localhost ~]# pvscan PV /dev/sda2 VG VolGroup lvm2 [19.51 GiB / 0 free] Total: 1 [19.51 GiB] / in use: 1 [19.51 GiB] / in no VG: 0 [0 ] [root@localhost ~]# pvcreate /dev/sd[bcd] 把bcd磁盘都设置为... 阅读全文
posted @ 2013-08-02 22:23 you Richer 阅读(426) 评论(0) 推荐(0) 编辑

POJ 3280 Cheapest Palindrome

摘要: Cheapest PalindromeTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 4592Accepted: 2236DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic ID tag that the system will read as the cows pa 阅读全文
posted @ 2013-08-02 22:21 you Richer 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 ··· 259 260 261 262 263 264 265 266 267 ··· 300 下一页