原创 Christmas is Halloween!

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

原创 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

原创 UVa Problem Solution: 10127 - Ones

We can solve this problem by simulating the calculating process of multiply two numbers on the paper, yet we've already

原创 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

原创 UVa Problem Solution: 10035 - Primary Arithmatic

Simple problem. Just count it.Code:/************************************************************************* * Copyrig

原创 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 impl

原创 UVa Problem Solution: 10018 - Reverse and Add

Do what you are told to do.Code:/************************************************************************* * Copyright 

原创 UVa Problem Solution: 10037 - Bridge

Given the two fastest people as f1 and f2, f1 < f2, and the two slowest people as s1 and s2, s1 < s2. We want to use th

原创 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:/**************

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

Nothing worthy to mention.Code:/************************************************************************* * Copyright (

原创 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 number

原创 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

原创 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

原创 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

原创 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 k