杰拉斯的博客

网页中CSS实现超长英文、数字自动换行

杰拉斯 杰拉斯 | 时间:2012-04-02, Mon | 22,690 views
前端开发 

浏览器中对于英文、数字超出容器宽度的处理是将整个不包含空格的单词换行,而不将单词及数字截断,这种处理是人性化的,但有时候遇到超长英文或数字时,却因为这种处理方式而导致容器宽度被撑大,致使页面非常难看,而通过CSS我们可以使其强制换行:

word-break: break-word;

word-break: break-all;

word-wrap: break-word;

[ACM_HDU_1297]Children’s Queue一文中,题目中的英文单词仍人性化判断是否换行,而下面的超长数字则强制自动换行。

[ACM_HDU_1297]Children’s Queue

杰拉斯 杰拉斯 | 时间:2012-04-01, Sun | 21,614 views
编程算法 

Children’s Queue

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5660 Accepted Submission(s): 1755

Description

There are many students in PHT School. One day, the headmaster whose name is PigHeader wanted all students stand in a line. He prescribed that girl can not be in single. In other words, either no girl in the queue or more than one girl stands side by side. The case n=4 (n is the number of children) is like
FFFF, FFFM, MFFF, FFMM, MFFM, MMFF, MMMM
Here F stands for a girl and M stands for a boy. The total number of queue satisfied the headmaster’s needs is 7. Can you make a program to find the total number of queue with n children?

Input

There are multiple cases in this problem and ended by the EOF. In each case, there is only one integer n means the number of children (1<=n<=1000)

Output

For each test case, there is only one integer means the number of queue satisfied the headmaster’s needs.

(阅读全文…)

[ACM_HDU_1005]Number Sequence

杰拉斯 杰拉斯 | 时间:2012-04-01, Sun | 25,208 views
编程算法 

Number Sequence

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 53991 Accepted Submission(s): 12146

Description

A number sequence is defined as follows:

f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.

Given A, B, and n, you are to calculate the value of f(n).

Input

The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1 <= n <= 100,000,000). Three zeros signal the end of input and this test case is not to be processed.

Output

For each test case, print the value of f(n) on a single line.

(阅读全文…)

探寻C++最快的读取文件的方案

杰拉斯 杰拉斯 | 时间:2012-03-31, Sat | 8,994 views
编程算法 

在竞赛中,遇到大数据时,往往读文件成了程序运行速度的瓶颈,需要更快的读取方式。相信几乎所有的C++学习者都在cin机器缓慢的速度上栽过跟头,于是从此以后发誓不用cin读数据。还有人说Pascal的read语句的速度是C/C++中scanf比不上的,C++选手只能干着急。难道C++真的低Pascal一等吗?答案是不言而喻的。一个进阶的方法是把数据一下子读进来,然后再转化字符串,这种方法传说中很不错,但具体如何从没试过,因此今天就索性把能想到的所有的读数据的方式都测试了一边,结果是惊人的。

(阅读全文…)

[ACM_HDU_2046]骨牌铺方格

杰拉斯 杰拉斯 | 时间:2012-03-31, Sat | 9,535 views
编程算法 

骨牌铺方格

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14699 Accepted Submission(s): 7085

Description

在2×n的一个长方形方格中,用一个1× 2的骨牌铺满方格,输入n ,输出铺放方案的总数.
例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图:

骨牌铺方格

Input

输入数据由多行组成,每行包含一个整数n,表示该测试实例的长方形方格的规格是2×n (0<n<=50)。

Output

对于每个测试实例,请输出铺放方案的总数,每个实例的输出占一行。

(阅读全文…)