## [整理]ACM详解（4）——递归

Problem Description

Input

Output

(阅读全文…)

## 5、Prime Ring Problem

Problem Description

A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.

Note: the number of first circle should always be 1.

Input

n (0 < n < 20).

Output

The output format is shown as sample below. Each row represents a series of circle numbers in the ring beginning from 1 clockwisely and anticlockwisely. The order of numbers must satisfy the above requirements. Print solutions in lexicographical order.

You are to write a program that completes above process.

Print a blank line after each case.

(阅读全文…)

## 1、Self Numbers

Description

In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d stands for digitadition, a term coined by Kaprekar.) For example, d(75) = 75 + 7 + 5 = 87. Given any positive integer n as a starting point, you can construct the infinite increasing sequence of integers n, d(n), d(d(n)), d(d(d(n))), .... For example, if you start with 33, the next number is 33 + 3 + 3 = 39, the next is 39 + 3 + 9 = 51, the next is 51 + 5 + 1 = 57, and so you generate the sequence 33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ... The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100. A number with no generators is a self-number. There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.

Input

No input for this problem.

Output

Write a program to output all positive self-numbers less than 10000 in increasing order, one per line.

(阅读全文…)

## [整理]ACM模拟题讲解（1）-高精度

Java中提供了byte、short、int和long表示整数，float和double来表示浮点数，每种类型都有一定的表示范围，当超过了这个范围之后就不能处理了。为了提供对非常大的整数和浮点数的处理，Java提供了BigDecimal和BigInteger。下面的代码演示了BigDecimal和BigInteger的基本用法：

```BigDecimal data1 = new BigDecimal("23232123456789.123456789");
BigDecimal data2 = new BigDecimal("23423423123456789.123456789");
System.out.println(data3.toString());
BigInteger iData1 = new BigInteger("123123123456456789789123456789");
BigInteger iData2 = new BigInteger("12312312323232456456789789123456789");
System.out.println(iData3.toString());
```

(阅读全文…)

## 关于Web语义化

“我们大部分人都有深刻体验，每当主流浏览器版本的升级，我们刚建立的网站就可能变得过时，

(阅读全文…)