现在位置: 首页 > poise发表的所有文章
  • 08月
  • 21日
综合 ⁄ 共 2047字 评论关闭
Strategic game Time Limit: 2000MS   Memory Limit: 10000K Total Submissions: 6260   Accepted: 2883 Description Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieval city, the roads of which form a tree. He has to put the minimum number of soldiers on the nodes so that they can observe all the edges. Can you help him?  Your program ......
阅读全文
  • 07月
  • 25日
综合 ⁄ 共 641字 评论关闭
Permutations Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. Permutations II Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1]. 思路: 反复生成permutation即可。生成permutation的思路可以看这里。当然题解里就用std::next_pe......
阅读全文
  • 03月
  • 25日
综合 ⁄ 共 3807字 评论关闭
    原博客 javax.crypto.Cipher类提供加密和解密功能,该类是JCE框架的核心。 一,与所有的引擎类一样,可以通过调用Cipher类中的getInstance静态工厂方法得到Cipher对象。 public static Cipher getInstance(String transformation); public static Cipher getInstance(String transformation,String provider); 参数transformation是一个字符串,它描述了由指定输入产生输出所进行的操作或操作集合。 参数transformation总是包含密码学算法名称,比如DES,也可以在后面包含模式和填充方式。 参数transformation可以是下......
阅读全文
  • 02月
  • 10日
综合 ⁄ 共 1223字 评论关闭
贪心:按照宽从小到大,高从小到大,将alice和bob的卡片排序,如果宽高相同,则alice的在后面。这样所有卡片排成一排了。 每次找到alice的卡片之后,覆盖她前面的最接近她的bob的那张卡片(尽量让这张卡片最有用),然后去除掉。 #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <string> #include <vector> #include <set> #include <queue> #include <stack> #include <c......
阅读全文
  • 12月
  • 20日
综合 ⁄ 共 1754字 评论关闭
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1548 题意:        有一个特别的电梯,第i层有一个对应的数字ki, 对于第i层按上升键up可升上到i+k[i]层,按下降键down到达i-k[i]层,到达的楼层最高不能超过n层,最低不能小于1层。给你一个起点A和终点B,问最少要按几次上升键或者下降键到达目的地,不可达则输出-1。 分析:       可以这构造成边权值为1的有向图,问题就可以变成求起点到终点的最短路径问题。       可以用 最短路径算法 or BFS  code1: (BFS) Accepted 1548 0MS 228K 1109 B G++ #includ......
阅读全文
  • 09月
  • 28日
综合 ⁄ 共 1615字 评论关闭
Java SE在5.0后增加了泛型,而C++一直支持泛型,并有强大的STL。 C++的泛型其实就是一个模板生成器,缺点是代码膨胀,而JAVA的泛型和C++采取的机制完全不同,它利用“擦除”的方式把类型参数替换为限定类型(无限定类型的替换为Object),然后再编译时插入类型安全的类型转换。 【C++ code】 template<typename T> class Base{ public:     virtual string GetInfo() {return "Base::GetInfo";} }; template<typename T> class Derived: public Base<T> { public:     string GetInfo() {return "Derived::GetInfo"......
阅读全文
  • 08月
  • 17日
综合 ⁄ 共 574字 评论关闭
import java.util.Comparator; import com.hblb.share.entity.Nav2; public class Compare implements Comparator { /* * 这里表示按Order_id()从小到大排序,如果该对象o1小于、等于或大于指定对象o2,则分别返回负整数、零或正整数 * 如果需要从大到小排序,则如果对象o1小于、等于或大于指定对象o2,则分别返回正整数、零或负整数 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override public int compare(Object o1, Object o2) { Nav2......
阅读全文
  • 06月
  • 05日
综合 ⁄ 共 4033字 评论关闭
自定义Writable Hadoop虽然 已经实现了一些非常有用的Writable,而且你可以使用他们的组合做很多事情,但是如果你想构造一些更加复杂的结果,你可以自定义Writable来达到你的目的,我们以注释的方式对自定义Writable进行讲解 /** * 自定义Writable通常都要实现Writable接口 * 如果有比较大小的业务,最好是实现WritableComparable接口 * @author 廖*民 * time : 2015年1月13日下午1:39:12 * @version */ public class EmployeeWritable implements WritableComparable<EmployeeWritable>{ //姓名 private Text nam......
阅读全文
  • 05月
  • 05日
综合 ⁄ 共 1497字 评论关闭
1抽象类 (1) 抽象方法只作声明,而不包含实现,可以看成是没有实现体的虚方法 (2) 抽象类不能被实例化 (3) 抽象类可以但不是必须有抽象属性和抽象方法,但是一旦有了抽象方法,就一定要把这个类声明为抽象类 (4) 具体派生类必须覆盖基类的抽象方法 (5) 抽象派生类可以覆盖基类的抽象方法,也可以不覆盖。如果不覆盖,则其具体派生类必须覆盖它们。如: using System; public abstract class A //抽象类A { private int num=0; public int Num //抽象类包含属性 { get { ......
阅读全文
  • 05月
  • 03日
综合 ⁄ 共 809字 评论关闭
 题目描述:  任意给出两个英文字母,比较它们的大小,规定26个英文字母A,B,C.....Z依次从大到小。 输入要求: 第一行输入T,表示有T组数据;接下来有T行,每行有两个字母,以空格隔开; 输出要求: 输出各组数据的比较结果,输出格式见样例输出;(注意输出严格按照输入的顺序即输入是A B,输出时必须是A>B) 输入样例: 3 A B D D Z C 输出样例: A>B D=D Z<C 解析: 先不多说,直接上代码(C语言版),提供两种判断! #include <stdio.h> int main() { int T; char a, b; scanf("%d",&T); while(T--)......
阅读全文
  • 03月
  • 20日
综合 ⁄ 共 1622字 评论关闭
大家都知道Form有个AcceptButton属性.......就是绑定一个button,然后不管当前焦点在窗体(Form)的某个控件上,只要按回车就会响应相应的button事件... this.AcceptButton = button1;  //按回车就会响应button1的Click事件 但是这个只能实现回车啊....如果想实现Ctrl + Enter或者其他的Ctrl+ XXX 怎么办呢(如:QQ一样,按Ctrl + Enter发送消息)..... 很多人马上会想到用KeyDown 事件.......没用,如果焦点不在Form上..不会响应这个事件的 ,于是乎可能这个时候很多人想到了用什么API 函数实现...满世界的找相关的信息... 甚至上CSND上......
阅读全文
  • 01月
  • 28日
综合 ⁄ 共 1141字 评论关闭
接口 nodeType常量 nodeType值 备注 Element Node.ELEMENT_NODE 1 元素节点 Text Node.TEXT_NODE 3 文本节点 Document Node.DOCUMENT_NODE 9 document Comment Node.COMMENT_NODE 8 注释的文本 DocumentFragment Node.DOCUMENT_FRAGMENT_NODE 11 document片断 Attr Node.ATTRIBUTE_NODE 2 节点属性 方法 描述 createAttribute() 用指定的名字创建新的Attr节点。 createComment() 用指定的字符串创建新的Comment节点。 createEle......
阅读全文