- 博客(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 1128
原创 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 789
原创 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 11491 1
原创 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 713
原创 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 749
原创 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 8516
原创 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 3137 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 4331 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 2647
原创 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 2641
原创 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 3902 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 2748
原创 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 1799
原创 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 1602
原创 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 2328
原创 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 3687 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 2929 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 3822 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 1184
原创 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 2834
原创 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 3122
原创 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 2701
原创 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 2512 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 3078
原创 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 1917
原创 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 1307
原创 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 2101
原创 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 1911
原创 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 2901
原创 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 942
原创 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 977
原创 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 450
原创 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 2015
原创 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 1992 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 2271
原创 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 2130
原创 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 1898 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 3049
原创 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 2198
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人