- 博客(33)
- 资源 (3)
- 收藏
- 关注
原创 一个分号引发的“血案”
再多的表情也无法诠释我现在的心情!!!!!!!!A+B for Matrices这是很水的一道题,然而却整整折腾了我2个多小时。从晚上6点多开始,花了没几分钟就把代码敲好了,可是数据一测,竟然不对,然后就开始找问题,找了很久,我竟然都还没看出问题在哪,越找心里越不爽,这么做明明对的呀,一运行怎么就错了呢?一直到了8点,同学来叫我跑步去,我都没看出来(眼神差上不起啊)
2013-09-09 22:29:28
797
原创 HDU 1312 Red and Black
/*http://acm.hdu.edu.cn/showproblem.php?pid=1312*/#include #include #include #include #include #include using namespace std;typedef struct point{ int x,y;}point;char block[25][25];int
2013-09-03 18:29:06
524
原创 HDU 1879 继续畅通工程
/*http://acm.hdu.edu.cn/showproblem.php?pid=1879*/#include #include #include typedef struct edge{ int a,b,c,f; //a,b 是边的两个顶点 c 是费用 f 表示是否建路 }edge;edge tree[110*110/2];int pa[110];int n,m,
2013-08-23 21:51:42
570
原创 HDU 1232 畅通工程
/*http://acm.hdu.edu.cn/showproblem.php?pid=1232merge 写错了,测试用例结果却还是正确的, 浪费了很长的时间以后注意要!!!!!!!!!!!!! */#include #include int pa[1010];int temp[1010];int find(int x){ return pa[x]==x?x:fin
2013-08-23 17:50:50
458
原创 Hibernate 4 二级缓存配置
打开二级缓存在hibernate.cfg.xml中配置true true org.hibernate.cache.ehcache.EhCacheRegionFactory truehibernate.cache.use_second_level_cache 为 true是打开二级缓存(实验证明不配该项也是可以的,二级缓存应该是默认就开启的)特别要注意的是hi
2013-08-22 23:00:01
1367
原创 HDU 1102 Constructing Roads
/*http://acm.hdu.edu.cn/showproblem.php?pid=1102*/ #include #include #define INF 100000000int tree[110][110];int intree[110];int nontree[110];int main(){ freopen("input.txt","r",stdin);
2013-08-22 15:42:44
644
原创 HDU 1856 More is better
/*http://acm.hdu.edu.cn/showproblem.php?pid=1856求子集个数最大值 */#include #include int boy[10000010];int fre[10000010];int find(int x){ int p = boy[x]; while(p!=x) { x = p; p = boy[x]; }
2013-08-21 13:12:07
507
原创 HDU 1325 Is It A Tree?
/*http://acm.hdu.edu.cn/showproblem.php?pid=1325deg 数组表示 节点的入度 -1 表示没有该节点 如果 有两个 入度为 0 的节点 则 不是一颗树如果 有个节点的入度 大于 1 则 不是一颗树 */#include #include int tree[10010];int deg[10010];int merge(in
2013-08-20 17:22:19
534
原创 HDU 1272 小希的迷宫
/*http://acm.hdu.edu.cn/showproblem.php?pid=1272 由于房间号不是连续的 ,所以 初始化maze为-1 来表示 没有该房间 */#include int maze[100010];int find(int x){ int p = maze[x]; if(p==-1) p=maze[x]=x; while(p!=x) {
2013-08-20 16:01:31
477
原创 HDU 1213 How Many Tables
/*http://acm.hdu.edu.cn/showproblem.php?pid=1213并查集 */#include int table[1010];int find(int x){ int p = table[x]; while(p!=x) { x = p; p = table[x]; } return p;}int len(int x)
2013-08-20 14:28:29
529
原创 01背包 问题 思路 整理
问题描述:有N个物品,每种物品只要一件,和容量为W一个背包,每个物品的价值为v[i],花费为w[i](此处的花费就是大小),问,将哪些物品装入背包中使得背包中的物品价值最大。因为每个物品只有一件,则对该物品而言只要放入背包和不放人背包两种可能。所以叫0/1背包。对于这类问题,现在来整理一下解题思路。w[i] 表示 第 i 个物品的 重量v[i] 表示 第 i
2013-08-16 16:22:29
801
原创 hdu 1159 Common Subsequence
/*http://acm.hdu.edu.cn/showproblem.php?pid=1159动态规划dp[i][j] 表示 对于 字符串x前i 个字符 和字符串y 的前 j 个字符的最大相同子串初始值:dp[0][0]=dp[0][1]=dp[1][0]=0对于 i ,j 如果 x[i]==x[y] 则 dp[i][i]=dp[i-1][j-1]如果x[i]!=y[j]
2013-08-14 14:02:15
482
原创 Hibernate 初步入门
首先是配置开发环境将hibernate 4.2.1的压缩包解压后得到三个文件夹:documentation、lib、project。分别是文档、jar包、源码。将lib中的required文件夹下的所有jar拷过去。然后将project文件夹下的etc文件夹下的hibernate.cfg.xml文件拷到src目录下。这样基本的开发环境算是完成。hibernate.cfg.xml的内容如下:
2013-08-13 18:25:10
541
原创 HDU 1421 搬寝室
/*http://acm.hdu.edu.cn/showproblem.php?pid=1421动态规划无法用贪心!!!!对于 这六个数 要搬3对 :3 4 7 9 10 13: 如果用贪心,则是 3 4 然后 9 10 然后 7 13 总的疲劳值为 38而 最小的 方案应该是 3 4 、 7 9 、 10 13 疲劳值为 14 首先 对 物品的重量进行从小到大排序 用 d
2013-08-13 14:34:10
440
原创 1087 Super Jumping! Jumping! Jumping!
/*http://acm.hdu.edu.cn/showproblem.php?pid=1087动态规划 题目是 要求 求出 升序和最大的那个值 从最后那 个 棋子 开始思考,如果 最后的结果 包括这个棋子, 则,从这个 棋子 开始的最大值 就是该棋子的值,因为后面没有棋子了考虑倒数第二个 棋子, 如果最后的结果包含这个棋子,则从这个棋子开始的最大值 取决于 这个棋子是否能再
2013-08-12 23:03:23
429
原创 1176 免费馅饼
/*http://acm.hdu.edu.cn/showproblem.php?pid=1176与数塔是一样的 f[i][j] = get_max(f[i + 1][j], f[i + 1][j + 1], f[i + 1][j - 1]) + f[i][j]*/ #include #include long long dp[100010][15];int main()
2013-08-12 23:02:11
449
原创 2084 数塔
/*http://acm.hdu.edu.cn/showproblem.php?pid=2084动态规划: 使用二维数组来表示 数字从底开始网上推,在最底的那一行,每个位置的最大值就是那个位置的值倒数第二行,每个位置的最大值 是 那个位置的 值 加上 最后一行 相邻的 位置 中 最大的那个值,....一直到第一行,则第一行的最大值就是第一行的值 加上 第二行的 最大值
2013-08-12 23:00:51
578
原创 HDU 1789 Doing Homework again
http://acm.hdu.edu.cn/showproblem.php?pid=1789/*http://acm.hdu.edu.cn/showproblem.php?pid=1789贪心: 对 score 进行 按 分数高低 排序 ,score 相同的 deadline 小的 排前面对 score 进行遍历, 每次 都将 score 大的 安排在 对应的 de
2013-07-31 16:05:14
422
原创 10878 - Decode the tape
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1819#include #include #include using namespace std;/*o 代表1空格 代表 0. 忽略由这些
2013-07-29 17:32:46
436
原创 10361 - Automatic Poetry
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1302#include #include #include using namespace std;char line1[110];char line2[11
2013-07-29 17:31:42
410
原创 457 - Linear Cellular Automata
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=398#include #include using namespace std;int main(){ int cases; int dna[10]; c
2013-07-29 17:30:57
577
原创 694 - The Collatz Sequence
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=635#include #include using namespace std;int nums[1024];int main(){ memset(nums
2013-07-29 17:29:11
497
原创 489 - Hangman Judge
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=430#include #include using namespace std;int main(){ int round; int wrongtimes
2013-07-29 17:28:00
445
原创 445 - Marvelous Mazes
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=386#include #include #include #include using namespace std;int main(){ cha
2013-07-29 17:25:37
537
原创 490 - Rotating Sentences
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=431#include #include #include #include using namespace std;char sents[110][1
2013-07-29 17:23:44
427
原创 414 - Machined Surfaces
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=show_problem&problem=355两边都一起想中间靠,当第一个接触后,求得离的最远的距离#include #include using namespace std;int main
2013-07-29 17:20:00
491
原创 401 - Palindromes
#include #include #include #include using namespace std;char one[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";char two[] = "A 3 HIL JM O 2TUVWXY51SE Z 8 ";int len = 35;int isPali(char str[]
2013-07-29 17:13:13
623
原创 Intellij IDEA 在启动tomcat时就出错
昨天晚上第一次用Intellij IDEA 在启动tomcat时就出错,一开始还以为自己的配置过程有问题,然后上网找了配置过程,跟着一步一步配置,启动tomcat时还是出同样的错!然后无奈的上网搜,发现根本搜不到相关的东西!于是,在csdn论坛上发了帖子求助,挺晚了就洗洗睡了。今天早上起床想看看有没有人回复,能把这问题解决掉。打开帖子一看,0回复。额,好吧,自己再看看这错误。这人刚睡醒,状态是
2013-06-07 09:51:59
25647
3
原创 静态内部类 笔记
import java.io.*;class Instanceof { public static void main(String[] args) throws Exception { new Instanceof().test(); } public void test() throws Exception{ System.out.println(new Inner());
2013-06-06 16:10:21
627
原创 instanceof 运算符 笔记
import java.io.*;class Instanceof { public static void main(String[] args) { Object hello = "Hello"; System.out.println("hello is a instance of Object "+(hello instanceof Object)); System.
2013-06-06 16:03:52
638
转载 逆波兰表达式
逆波兰表达式(转自http://zha-zi.iteye.com/blog/1271521)逆波兰表达式又叫做后缀表达式。在通常的表达式 中,运算符总是置于与之相关的两个运算对象之间,所以,这种表示法也称为中缀表示。波兰逻辑学家 J.Lukasiewicz于1929年提出了另一种表示表达式的方法。按此方法,每一运算符都置于其运算对象之后,故称为后缀表示。逆波兰表达式,它的语法规定,表达
2013-05-17 16:52:41
555
原创 类是如何被初始化的
在写Dao工厂的时候遇到了这么一个问题:每次访问数据的时候总是出错,提示下面的代码 daoconfig.load(int) 出错!public class DaoFactory { private static DaoFactory factory = new DaoFactory(); private static Properties daoconfig = new Propert
2013-05-16 17:39:11
570
转载 DOM4J的中文乱码问题
原文地址:(转)Dom4j中的中文编码问题如果用之前的解决中文问题的方法,输出的XML文件编码为GBK,改成UTF-8就会出错;如果把Format编码设置为UTF-8或不做任何事情(其默认会生成“”),生成的XML文件只能用文本打开,用浏览器会出现错误,不过通过文本“另存为..”设置编码为UTF-8再打开就正常了。我是看第二种方法解决的问题,还明白了XML文件头部的encoding="ut
2013-04-23 20:12:09
2029
Java大学教程
2011-11-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人