上一页 1 ··· 3 4 5 6 7 8 下一页

2013年6月12日

EOJ 1028 路由器

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1028这题以字符串作为节点,有一个字符串映射到节点序号1……N的问题,可以用map来解决这题数据不大,所以可以直接用floyd算法 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 const int INF = 9999999;10 int m[102][102];11 mapmy;12 int n;13 14 void floyd()15 {16... 阅读全文

posted @ 2013-06-12 22:21 KimKyeYu 阅读(245) 评论(0) 推荐(0) 编辑

EOJ 1031 传球问题

摘要: EOJ 1031 http://acm.cs.ecnu.edu.cn/problem.php?problemid=1031题意: 传球问题,按题意我们得到编号从1~2~..~ i ~..~n~1的环,那么去掉末尾的1(将环从n后剪开), 我们得到:1~2~..~ i ~..~n,多了首尾不同的限制,于是问题完全等价 HDU 2045 —— 染色问题(做过这题的话,很容易想到)。 HDU 2045 http://acm.hdu.edu.cn/showproblem.php?pid=2045 具体分析: n为传球总次数,i 一个空位, 待填入接到第 i-1 次传球的人; 又有p个人,... 阅读全文

posted @ 2013-06-12 18:42 KimKyeYu 阅读(274) 评论(0) 推荐(0) 编辑

EOJ 1027 邮资的问题

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1027题意:给N种邮票,第 i 种邮票面值为c[i], 有amt[i]张, 问,用这些邮票,可以贴出多少面额不同的邮资。思路: 一看就是须装满的多重背包(参见lrj背包九讲)。只不过问的是有多少不同面值, 也即有多少种不同容量的背包能被装满。 如果改成这样问:给定一个面额,有多少种贴法,那就和 poj 1837 差不多了。 具体的: 把每个邮票看成一个容量为c[i]的物品,dp[i][j]表示第i个物品放完后容量为j的背包的状态, dp[i][j] = 0:未满,dp[i][j... 阅读全文

posted @ 2013-06-12 15:00 KimKyeYu 阅读(324) 评论(0) 推荐(0) 编辑

EOJ-2941 在线投票系统

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=2941如题意进行加密操作,求出加密前的数字。已知: a^b=b^a , a^b^b=a以n=2为例,则a=a^g[0][0]^g[0][1]^g[1][0]^g[1][1]设加密前的数字为x1,x2,x3,x4,已知加密后的为y1,y2,y3,y4则y1=x1^g[0][0]^g[0][1]^g[1][0]^g[1][1] ; y2=x2^g[0][0]^g[0][1]^g[1][0]^g[1][1] ;…………所以若想求出xi 只要式子两边同时异或g[0][0]^g[0][1]^g[1][0]^ 阅读全文

posted @ 2013-06-12 03:46 KimKyeYu 阅读(222) 评论(0) 推荐(0) 编辑

EOJ-2530 数字之和

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=2530题意:求一个数组中是否存在三个数的和为0。n=1000,朴素的n^3会超时,故用二分搜索,即是把正负数存入不同的两个数组,在一个数组中任取两个,求和,然后在另一个数组中利用二分查找其相反数是否存在, 复杂度将降为n^2logn 级别 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 using namespace std;11 bool b_ 阅读全文

posted @ 2013-06-12 03:38 KimKyeYu 阅读(317) 评论(0) 推荐(0) 编辑

EOJ-2529 强大的lwc

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=2529题意,求修造为通路耗费的最小精力。即求无向图的最小生成树,此题注意结点是0到n 为n+1个,判断连通条件可以判断树的边数是不是为n,此题用prim 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 using namespace std;11 const int inf=999999999;12 int mat[105][105];13 in 阅读全文

posted @ 2013-06-12 03:33 KimKyeYu 阅读(211) 评论(0) 推荐(0) 编辑

EOJ-2124 Seamild的电梯

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=2124题意,电梯第i层能上升Ki层或下降Ki层,问从a到b的最短操作次数最短路floyd,建图时即是把x到x+ki x-ki (若存在)赋值为1,开始存为inf。 1 #include 2 #include 3 #include 4 using namespace std; 5 int mat[105][105]; 6 const int inf=99999999; 7 void floyd(int n){ 8 for(int k=1;k0) mat[i][i-x]=1; ... 阅读全文

posted @ 2013-06-12 03:25 KimKyeYu 阅读(148) 评论(0) 推荐(0) 编辑

EOJ-2032 判断两个数是否相等

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=2032测试数据必须用字符串处理,情况比较多,代码比较乱,仅说明思路。将两个字符串进行“正常化”,即变成正常的数据(没有符号,前置零等等)case 1: .xxxxx 即小数点前面无零 需在前加0。case 2: 前置符号+或-,记录一下符号,并去除、 #特殊情况: +. xxx 或 -. xxx 符号后面直接加小数点,需在前面加零。case 3:去除前置零: 00000xxxx 或者是00000000的情况,去除多余的零,但要小心0. XX的情况。case 4:去除后置0:即xx.xx000000 阅读全文

posted @ 2013-06-12 03:18 KimKyeYu 阅读(272) 评论(0) 推荐(0) 编辑

EOJ-1148 质数阵

摘要: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1148题意:在n*n的矩阵中填入1-n^2,使得任意两个相邻的数字之和为质数,并且输出符合条件的最小序列(就是指小数尽量在前)。dfs,从小数开始填,从左到右,从上到下的方法进行搜索,可以使得判断条件仅考虑与上面数字的和以及左面数字的和为质数,并且以此方法第一个填完的表即是最小序列。但方法依然比较朴素,故tle,无奈打表。由于tle,仅提供思路 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio&g 阅读全文

posted @ 2013-06-12 02:52 KimKyeYu 阅读(288) 评论(0) 推荐(0) 编辑

EOJ 1199 Anagram

摘要: EOJ 1199: http://acm.cs.ecnu.edu.cn/problem.php?problemid=1199poj 1256: http://poj.org/problem?id=1256题意不难理解: 给定一个字符串,让你完成:全排列+去重+排序; 最坑的是排序:poj 中有说明: hint: An upper case letter goes before the corresponding lower case letter. So the right order of letters is 'A'<'a'<'B' 阅读全文

posted @ 2013-06-12 02:03 KimKyeYu 阅读(278) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 下一页

导航