自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Kaipeng Liu's Column

BEYOND REDEMPTION

  • 博客(70)
  • 收藏
  • 关注

原创 I Love Big Numbers!

My big integer class is finally finished. I have not tested it extensively yet. Anybody who is willing to find a tiny and clearly implemented big number class would find it worthy to have a try. Bug r

2008-12-03 01:26:00 1111

原创 Miscellaneous algorithms

1. Generate Permutations/* Rearranges the elements in the array into the lexicographically next    greater permutation of elements. */int next_permutation(int p[], int n){  int i, j;  for (i = n - 2; 

2008-10-29 15:51:00 779

原创 UVa Problem Category (Programming Challenges)

General100 - The 3n+1 problem | Solution10189 - Minesweeper | Solution10137 - The Trip | Solution706 - LC-Display | Solution10267 - Graphical Editor | Solution10033 - Int

2008-10-23 19:29:00 11440 1

原创 iPhone4离线地图制作

iPhone4离线地图制作

2010-12-10 17:07:00 5910

原创 Conference List for Information Retrieval and Data Mining

SIGIR-20102010.1.15 : Abstracts for full research papers due2010.1.22 : Full research paper submissions due2010.2.12 : Posters, demonstration, and tutorial proposals du

2009-12-25 20:51:00 694

原创 Rubik's Cube Beijing Spring Open 2009

 Beijing Spring Open 2009 was held on Feb. 21st, 2009. I played in the game and passed the first round with a rank of 16th. Unfortunately, I ranked 24th in the second round and was not qualified to

2009-02-24 11:34:00 726

原创 UVa Problem Solution: 861 - Little Bishops

 Imagine that a chessboard with black and white squares. If a bishop is on a white square, can it attack bishops on black squares? No.So you can divide the chessboard into two independent ones. Th

2009-02-17 17:02:00 8495

原创 UVa Problem Solution: 10089 - Repackaging

 First, convert each package p = (s1, s2, s3) to a vector (s2 - s1, s3 - s1). All the packages forms convex hull. If point (0, 0) is in this convex hull, then there will be a solution, otherwise not

2009-02-13 17:32:00 3115 2

原创 UVa Problem Solution: 10090 - Marbles

 This problem requires us to find two non-negative numbers m1 and m2 that satisfying  n1*m1 + n2*m2 = nand minimize the cost  c = c1*m1 + c2*m2. First, we can use extended Euclids algorit

2009-01-19 18:56:00 4313 1

原创 UVa Problem Solution: 10042 - Smith Numbers

Follow the problems statements and youll get it.Code:/*************************************************************************** *   Copyright (C) 2008 by Liu Kaipeng                               

2009-01-08 18:09:00 2622

原创 UVa Problem Solution: 10168 - Summation of Four Primes

According to the Goldbachs Conjecture, every even number that is not less than 4 is the sum of two primes. So we can just reduce the number to an even number by subtracting 4=2+2 or 5=2+3 from it, an

2009-01-08 16:45:00 2622

原创 UVa Problem Solution: 10139 - Factovisors

We check each of the prime factors of m to see if n! has enough prime factors of the same value. If so, m can divide n!, otherwise m can not divide n!.Code:/*******************************************

2009-01-08 15:35:00 3881 1

原创 UVa Problem Solution: 10104 - Euclid Problem

For the detail explanation of the algorithm, refer to Programming Challenges.Code:/*************************************************************************** *   Copyright (C) 2008 by Liu Kaipeng    

2009-01-04 16:18:00 2721

原创 UVa Problem Solution: 10006 - Carmichael Numbers

Compute the remainder with the following equation:    (x*y)%n = (x%n)*(y%n)%nCode:/*************************************************************************** *   Copyright (C) 2008 by Liu Kaipeng    

2008-12-23 12:06:00 1780

原创 UVa Problem Solution: 10110 - Light, More Light

 The final state of the last bulb is determined by the number of factors of n. Only the number which is the square of a number has an odd number of factors, thus it has a state of "yes".Code:/********

2008-12-18 13:40:00 1583

原创 UVa Problem Solution: 846 - Steps

Let f(n) denote the furthest distance we can go with n steps, then we can derive this formula easily:   f(n) = ((n+1)/2)^2 if n is odd, (1, 2, 3, 4, 3, ,2, 1)    f(n) = (n/2)^2 + n/2 if n is even. (1,

2008-12-04 21:55:00 2306

原创 UVa Problem Solution: 10049 - Self-describing Sequence

Let g(n) denote the nth number that satifies f(k) > f(k-1). We can know that     g(0) = 1, g(1) = 2, g(2) = 4, ... From the definition of g(n), we can know that all the values of f(k) where k belongs

2008-12-04 20:01:00 3664 1

原创 UVa Problem Solution: 10254 - The Priest Mathematician

From the description of this problem we can easily draw the recurrence of   f(n) = 2*f(n-k) + 2^k - 1and the base cases of   f(0) = 0 and f(1) = 1However, how can we determine which k would give the m

2008-12-04 13:18:00 2908 2

原创 UVa Problem Solution: 10247 - Complete Tree Labeling

Let f(k, d) denote the number of labelings of the k-ary tree of depth d. Moreover, let n(k, d) denote the number of nodes of the tree. The tree contains k subtrees, each contains n(k, d-1) nodes. Ther

2008-12-04 00:25:00 3790 3

原创 UVa Online Jugde Automatic Posting Script

I develop a script to post my code to the UVa online judgeautomatically. This tool will also replace the local #includes withits real content when uploading the code to the server. So, I havent 

2008-12-03 18:03:00 1155

原创 UVa Problem Solution: 10157 - Expressions

Let n denotes the length of the expression, d denotes the depth at most, and the count is f(n,d). Obviously, f(n,d) = 0 when n is odd. For other conditions, let us consider where we can find the corre

2008-12-03 01:20:00 2810

原创 UVa Problem Solution: 10198 - Counting

 Let f(n) denote the number of ways to make the sum of n. When n > 3, the number of digits is greater than 1. The first digit d used must be one of 1, 2, 3 or 4. Remove the first digit, then the remai

2008-11-27 16:36:00 3096

原创 UVa Problem Solution: 10213 - How Many Pieces of Land?

I use this formula to calculate: f(n) = (n,4) + (n,2) + 1. Detailed explanation is available here.I really need to implement a big integer class. The following code is rather ugly.Code:/**************

2008-11-26 23:36:00 2679

原创 UVa Problem Solution: 10183 - How many fibs?

The close form of fibs does not help in the problem. The input range is too large that the precision of long double wont be sufficient to handle it correctly. Just generate all the fibs up to 100 dig

2008-11-26 15:57:00 2486 3

原创 UVa Problem Solution: 10202 - Pairsumonious Numbers

The problem is not as difficult as it is seen at first. Carefully examine the structure of the sums will give you the key inspiration.Let N[0..n] denotes the n numbers and S[0..n*(n-1)/2] denote the p

2008-11-25 17:28:00 3022

原创 UVa Problem Solution: 10077 - The Stern-Brocot Number System

Just like find a number in a binary search tree. The only trick is keeping record of the current nodes left and right node to get to its child node.Code:/*********************************************

2008-11-24 19:39:00 1899

原创 UVa Problem Solution: 10105 - Polynomial Coefficients

The coefficient of x1n1x2n2...xknk is (n, n1)(n-n1, n2)...(n-n1-n2-...-nk-1, nk) = n!/n1!n2!...nk!.Code:/************************************************************************* * Copyright (C) 2008 

2008-11-24 18:48:00 1285

原创 UVa Problem Solution: 847 - A Multiplication Game

We can easily observe that if the drawn number is in range [2, 9], Stan will win, and if it is in range [10, 18], Ollie will win. Suppose that one of Spans win range is [m, n], it can be extend to th

2008-11-24 17:44:00 2074

原创 UVa Problem Solution: 10127 - Ones

We can solve this problem by simulating the calculating process of multiply two numbers on the paper, yet weve already known the product. We guess the least significant digit of one number, multiply

2008-11-24 14:57:00 1886

原创 UVa Problem Solution: 701 - The Archaeologist's Dilemma

Let P denotes the prefix, T denotes the # of lost digits. We are searching for N, that the prefix of 2^N is P. We have an inequlity of    P*10^T thus    log2(P*10^T) which is    log2(P)+T*log2(10) Als

2008-11-24 13:29:00 2881

原创 UVa Problem Solution: 10018 - Reverse and Add

Do what you are told to do.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng                                      * * liukaipeng at gma

2008-11-24 10:28:00 925

原创 UVa Problem Solution: 10035 - Primary Arithmatic

Simple problem. Just count it.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng                                      * * liukaipeng at 

2008-11-23 18:05:00 959

原创 Christmas is Halloween!

The only joke based on base-conversion:Why do programmers think Christmas is Halloween? Because 31 Oct == 25 Dec.   

2008-11-23 15:13:00 433

原创 UVa Problem Solution: 10194 - Football (aka Soccer)

Nothing worthy to mention.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng                                      * * liukaipeng at gmai

2008-11-21 19:14:00 1998

原创 UVa Problem Solution: 10152 - ShellSort

Let the required stack to be the sorted sequence, and the original stack to be the sequence to sort. A turtle is numbered by its position in the required stack: the top is 0, the second is 1, and so o

2008-11-21 16:42:00 1976 1

原创 UVa Problem Solution: 10138 - CDVII

Sort the the photo records according to license number, then time. If a license has no cost, do not output it.Code:/************************************************************************* * Copyrigh

2008-11-21 13:33:00 2243

原创 UVa Problem Solution: 10026 - Shoemaker's Problem

Simply sort will do the job. Given to jobs, j1 and j2. which should be done first? Do j1 first will cause a total fine to j2 of j1.time * j2.fine and do j2 first will cause a total fine to j1 of j2.ti

2008-11-20 18:06:00 2113

原创 UVa Problem Solution: 10191 - Longest Nap

Quite simple question. I add two sentinels to avoid boundary checks. However, the input format is tricky to handle. At first, I use scanf("%2d:%2d %2d:%2d%*[^/n]/n, ...) to read the input. After some

2008-11-20 16:58:00 1876 1

原创 UVa Problem Solution: 10037 - Bridge

Given the two fastest people as f1 and f2, f1   1) f1, f2 go --> f1 back --> s1, s2 go --> f2 back: time1 = f2 + f1 + s2 + f2  2) f1, s1 go --> f1 back --> f1, s2 go --> f1 back: time2 = s1 + f1 + s2

2008-11-20 14:19:00 3029

原创 UVa Problem Solution: 120 - Stacks of Flapjacks

I just simulate the flipping. We are not required to find the optimal solution, so I choose a way easy to understand. I find the biggest cake in the unsorted stack, and then check its position. If it

2008-11-20 11:19:00 2180

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除