- 博客(34)
- 收藏
- 关注
原创 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 2511 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 976
原创 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 449
原创 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 3048
原创 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
原创 UVa Problem Solution: 10041 - Vito's Family
Vito should live on the street which is the median of his relatives.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng
2008-11-18 13:14:00 1308
原创 UVa Problem Solution: 848 - Fmt
At the first look, this problem seems to be tricky to solve. However, if you implement all the specifications precisely, it would be already solved. Theres no need to "translate" the problems specif
2008-11-17 12:59:00 1788
原创 UVa Problem Solution: 10150 - Doublets
This problem can be solved by a BFS on a graph that modeling the doublet relationships. If the pair of a and b forms a doublet, then there is a edge between a and b in the graph.You can divide the dic
2008-11-16 14:55:00 2703
原创 UVa Problem Solution: 10132 - File Fragmentation
I solve this problem in a manner that seems not straight forward. I let the fragments to "vote" on each bit if it is 0 or 1. Specifically, for each fragment, it is either the head or tail of the f
2008-11-14 15:31:00 2929 2
原创 UVa Problem Solution: 10188 - Automated Judge Script
Not a difficult problem. Just catenate the lines together and compare the correct and submitted answer will do it well. Unfortunately, the problem statement is misleading: I get WA consistently with a
2008-11-14 13:39:00 1740
原创 UVa Problem Solution: 850 - Crypt Kicker II
This problem is much easier than its brother, "843 - Crypt Kicker". Just find the key line and get the translate table from it will do all the job. I generate a "signature" for the key line to make th
2008-11-13 18:26:00 2652
原创 UVa Problem Solution: 10252 - Common Permutation
Really simple problem. However, two points need to be considered:1. ... find the largest string x such that there is a permutation of x that is a (not necessarily continuous) subsequence of a ...2. if
2008-11-13 15:48:00 1735
原创 UVa Problem Solution: 10010 - Where's Waldorf
I use the naive string search method that scans for the eight directions at each point in the matrix. Due to the relatively small input size, this method work well enough to get the top 20% ranking.Co
2008-11-13 15:04:00 2263
原创 UVa Problem Solution: 10082 - WERTYU
The simplest problem ever since...Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng
2008-11-10 18:18:00 1761
原创 UVa Problem Solution: 10149 - Yahtzee
Im stuck by this problem for two days. Finally I searched for some hints and came to this solution.The key points to solve this problem are: 1) using bitmap to record all the possible combinations,
2008-11-10 17:28:00 3308 2
原创 UVa Problem Solution: 10258 - Contest Scoreboard
Understanding the problem specification is the very key to solve it:1) ... penalty time is computed ... submission received prior to the correct solution: So if the AC submission (C) is before any ot
2008-11-06 20:03:00 2065
原创 UVa Problem Solution: 10044 - Erdos Number
The unclear specifications on the input format and size lead to the undeserving difficulties to solve this problem. After numerous frustrating REs and WAs, I was forced to switch to C++. Im still
2008-11-06 14:59:00 2675
原创 UVa Problem Solution: 10205 - Stack 'em Up
Simple simulation will do the job.Code:/************************************************************************* * Copyright (C) 2008 by liukaipeng * * liukaipeng
2008-11-04 16:15:00 1561
原创 Rubik's Cube Beijing Fall Open 2008
Beijing Fall Open 2008 was held on Nov 2nd. I played in the game and passed the first round. I was feeling nervous all the time since that was my first time to participate in a formal competition. Un
2008-11-03 13:34:00 568
原创 UVa Problem Solution: 843 - Crypt Kicker
This is the hardest problem ever since in this book. After some thinking, I realized that this problem can be solved with backtracking. After some more thinking, I realized that we should backtrack th
2008-11-03 12:34:00 4076 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人