代码改变世界

阅读排行榜

图论500题

2012-08-13 11:55 by javaspring, 253 阅读, 收藏,
摘要: =============================以下是最小生成树+并查集====================================== 【HDU】 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 1233 还是畅通工程 基础最小生成树★ 1863 畅通... 阅读全文

3087_Shuffle'm Up

2012-03-09 23:09 by javaspring, 253 阅读, 收藏,
摘要: DescriptionA common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips,S1andS2, each stack containingCchips. Each stack may contain chips of several different colors.The actual shuffle operation is perform 阅读全文

编程珠玑第八章

2012-07-27 12:23 by javaspring, 252 阅读, 收藏,
摘要: 1、求一个整型数组中相邻子向量的最大和。方法一:最直观的,也是最容易想到的,长度为n的数组,子向量个数为 n *(n+1)/ 2 ,找到和最大的子向量,复杂度为 O(n^2 )int findMax(int *a,int n) //a为待查找数组,n为数组长度 { int max=0,sum=0; for (int i=0;i<n;i++) { sum=0; for (int j=i;j<n;j++) { sum+=a[j]; max=max>sum?max:sum; } } return max; }改进方法:顺序查找整个数组,用maxSofar存... 阅读全文

SRM 543 Div2

2012-05-20 10:41 by javaspring, 252 阅读, 收藏,
摘要: 决定以后多做一些TC,即使做不了比赛,也要多做一些TC上的题,顺便写一些结题报告什么的。不过像我这种在Div2混的弱菜,也写不出什么高质量的结题报告,而且1000pt的题,我基本都不用看了,尽量把250和500的题写一下,1000的题目,能做出来的话就写一下。250:题意:给一个字符串,由‘C’和‘V’组成,一个人只能从‘C’到‘V’,或者从‘V’到‘C’,且可以从任意一个‘C’到达另一个‘V’,但是走过的字母不能再走,也就是说一个字母只能走一次。问:最多能走多少个字母。解法:其实是道水题了,字符串中的哪个字母少,便以哪个为起点,之后乘2加1就可以了。代码:class EllysTSP {.. 阅读全文

Java用LinkedList实现栈

2012-07-27 17:14 by javaspring, 251 阅读, 收藏,
摘要: import java.util.LinkedList; public class MyStack { private LinkedList ll=new LinkedList(); public void push(Object o) { ll.addFirst(o); } public Object pop() { if(ll.isEmpty()) { System.out.println("栈为空,不能出栈!"); return null; } return ll.removeFirst(); } public Object peek()... 阅读全文
上一页 1 ··· 55 56 57 58 59 60 61 62 63 ··· 126 下一页