- 博客(43)
- 问答 (2)
- 收藏
- 关注
多线程下载与断点续传
一个多线程下载与断点续传的demo... import java.io.*;import java.net.*;import java.util.concurrent.*;public class Downloader3 { URL url; File des; File cfg; long size; long sum; int taskNum =...
2010-03-23 14:29:37 119
一个简单的堆...
主要是支持对优先队列中某元素属性值的修改(通过equals查找, 并替换新的引用), 可以用于A*算法框架...import java.util.*;@SuppressWarnings("unchecked")public class Heap<E extends Comparable<E>>{ private E[] heap; // E[0] i...
2010-03-11 15:37:48 73
图论初级算法
图遍历算法 ---- DFS & BFS... public class GraphTraveler { LinkedList<Integer> open = new LinkedList<Integer>(); public void bfs(Graph g, int start) { int n = g.getVolume();...
2010-03-10 19:40:48 124
快速排序
快速排序有很多注意事项... public static void qsort(int[] a, int low, int high) { if (high < low + 2) return; int piv = low, end = high; while (low < high) { while (++low < end &&...
2010-03-09 10:09:45 62
八数码问题
搜索算法学问不小...总结:1. 状态表示用整数最快, 可是转化状态的代码不好写, 用字符串挺爽的, 可有些地方涉及到数字运算, 代码又不自然, 整来整去, 还是用byte[]好了...性能没比字符串强多少...2. open表用LinkedList就挺好, 支持队列和堆栈两种模型, 这点在双向广度优先搜索时候挺方便, closed表千万别用List类型, 用HashMap或者HashSet性能上...
2010-03-04 15:30:06 435
TCHS-12-950
Problem Statement An army of k knights is going to try to kill an evil dragon. The dragon has h heads, and the knights must cut off all his heads one by one to complete their miss...
2010-03-01 12:58:54 84
原创 TCHS-12-550
Problem Statement Let's consider a standard six-sided die. Each side contains a distinct number between 1 and 6. We can represent a single die as a sequence of 6 digits in the fol...
2010-03-01 10:04:32 256
原创 TCHS-12-250
Problem Statement In some of the old historical chronicles the Indict system of chronology was used. Instead of a year, this system uses three integers, called indict, circle to t...
2010-02-28 09:53:52 120
原创 TCHS-11-1000
Problem Statement You have beads of several different colors that are to be placed on a string, with the requirement that for any group of three adjacent beads, all three must hav...
2010-02-22 15:22:35 98
原创 TCHS-11-500
Problem Statement You are playing a game with some friends. The game is played on a rectangular chess board where each cell may be either empty or occupied by a rook. You are give...
2010-02-22 13:11:13 86
原创 TCHS-11-250
Problem Statement You are given a String[] blocks representing the layout of a city. Each character of each element of blocks represents one city block. A 'B' character represents...
2010-02-22 11:38:14 70
原创 TCHS-10-1000
Problem Statement You have a string s containing only ones and zeroes. Your goal is to make all the characters in s equal using a minimal number of operations. A single operation ...
2010-02-21 16:35:35 96
原创 TCHS-10-500
Problem Statement There are several cannons located on a plane. Each cannon is represented as a point, and can shoot in one of four directions: left, right, up or down. Given the ...
2010-02-21 15:16:49 91
原创 TCHS-10-250
Problem Statement Given a int[] x and a percentile p (between 0 and 100, inclusive), find the smallest element y in x such that at least p percent of the elements in x are less th...
2010-02-21 14:26:17 92
原创 TCHS-9-1000
Problem Statement Consider a square n x n matrix A. The cell Ai,j is equal to the product i * j (i, j are 1-based). Let's create a one-dimensional array which contains all the el...
2010-02-20 18:45:04 88
原创 TCHS-9-500
Problem Statement A simple way to compress a string is to encode repeated consecutive substrings as a counter followed by the substring. For example, if X represents a substring,...
2010-02-20 16:26:29 128
原创 TCHS-9-250
Problem Statement One day, nClassmates classmates decided to play an exciting game. They formed a circle and assigned themselves player numbers from 0 to nClassmates - 1 in a cl...
2010-02-20 15:24:33 86
原创 TCHS-8-1000
Problem Statement When scheduling tasks to be executed by a person, it is sometimes the case that when one task is completed, a later task suddenly becomes more important. In these ...
2010-02-19 11:57:09 101
原创 TCHS-8-500
Problem Statement A common task for math students is to solve 'word math' questions, where each distinct letter represents a distinct digit.Given a list of word math numbers to ...
2010-02-19 10:56:54 112
原创 TCHS-8-250
Problem Statement Last night, after that terrible nightmare about pink elephants, you decided that you would never again go to sleep unless the time showing on your digital clock wa...
2010-02-19 10:18:08 82
原创 TCHS-7-1000
Problem Statement You are given an even number of points in the plane. You want to find a rectangle whose corners have integer coordinates and sides are parallel to the axes, such...
2010-02-05 15:21:39 110
原创 TCHS-7-500
Problem Statement An array of ints is said to be a straight if it contains five elements that are five consecutive numbers. For example, the array { 6, 1, 9, 5, 7, 15, 8 } is ...
2010-02-05 13:45:26 88
原创 TCHS-7-250
Problem Statement You are given a String text. Determine the letters (both lowercase and uppercase) that appear in text. Return a String which contains those letters, converted to l...
2010-02-05 13:32:02 97
原创 TCHS-6-900
Problem Statement We are given a maze which is a cube of NxNxN cells. We start at (1,1,1) and we move to (N,N,N), in each move visiting one of the three adjacents cells in the pos...
2010-02-04 12:06:09 64
原创 TCHS-6-600
Problem Statement You have just hacked into your friend's computer, and you want to delete one of his personal files. But wait, why not let him delete it! As you keep watching him...
2010-02-04 11:33:07 80
原创 TCHS-6-250
Problem Statement A digital clock displays time in the format "DD:DD:DD" (quotes for clarity only), where each D is a single digit, and each pair of contiguous digits represents eit...
2010-02-04 09:56:24 99
原创 TCHS-5-1000
Problem Statement When programming, I don't like to take my fingers off the keyboard, and hence, I don't use the mouse. So, when navigating my source, I like to do so in such a way ...
2010-02-02 14:47:05 189
原创 TCHS-5-500
Problem Statement A sentence is composed of words, spaces and punctuation. For this problem, words are maximal contiguous strings of letters. Given a sentence, sort the words in the...
2010-02-02 12:43:40 114
原创 TCHS-5-250
Problem Statement When shopping for TVs consumers may notice that a TV's size is given by its diagonal in inches. The aspect ratio of a screen is the ratio of its width to its heigh...
2010-02-02 12:41:59 70
原创 TCHS-5-600
Problem Statement Masterbrain is a two player board game in which one player decides on a secret combination of digits, while the other must figure it out in 10 guesses or less. T...
2010-01-30 14:08:39 91
原创 TCHS-5-300
Problem Statement Given the width and height of a rectangular grid, return the total number of rectangles (NOT counting squares) that can be found on this grid. For example, wid...
2010-01-30 13:15:12 79
原创 TCHS-4-1100
Problem Statement Your master construction unit can build 1 unit of type 0 in times[0] seconds at a cost of costs[0]. Each unit of type 0, once built, can in turn build 1 unit of ty...
2010-01-30 10:52:27 69
原创 TCHS-4-500
Problem Statement In music, each note has a relative duration. For example, a whole note lasts four times longer than a quarter note. Half notes, eighth notes, and sixteenth notes...
2010-01-30 09:20:03 92
原创 TCHS-4-250
Problem Statement You will be running a race on a straight track, and you have devised the following trick to help you win. The weather forecast for the day of the race indicat...
2010-01-30 08:58:58 69
原创 TCHS-3-1000
Problem Statement A decomposition of a non-negative integer n is a list of non-negative integers that sum to exactly n. The product of a decomposition is the product of all its me...
2010-01-29 15:11:04 67
原创 TCHS-3-450
Problem Statement Three kids are playing the following game: A word is written on a sheet of paper, and one after another, the players take turns adding letters to the word. Durin...
2010-01-29 13:45:13 130
原创 TCHS-3-250
Problem Statement After selling goods all day, a salesman would like to determine the most desirable item in his inventory. You are given a String[] items, each element of whic...
2010-01-28 14:58:37 95
原创 TCHS-2-1000
Problem Statement A spell is defined by its incantation, the word spoken when the spell is being cast. If you know the incantation of a spell, you can create counterspells in the...
2010-01-28 11:43:44 141
原创 TCHS-2-500
Problem Statement The number 666 is considered to be the occult "number of the beast" and is a well used number in all major apocalypse themed blockbuster movies. However the number...
2010-01-28 09:22:52 81
原创 TCHS-2-250
Problem Statement A Fountain of Life is a special fountain that produces the elixir of life at a constant speed of elixir liters per second. A dark mage managed to cast a Curse of D...
2010-01-28 08:58:50 108
空空如也
关于Vim窗口的一个问题...
2009-11-30
GAE for Java现在还能申请吗, 有知道消息的吗?
2009-05-15
TA创建的收藏夹 TA关注的收藏夹
TA关注的人