Currently browsing

May 2017

ACM 题目解答:寄居蟹与海葵

Description
寄居蟹与海葵是一对合作互助的共栖伙伴。海葵是寄居蟹最称职的门卫。它用有毒的触角去蜇那些敢来靠近它们的所有动物,保护寄居蟹。而寄居蟹则背着行动困难的海葵,四出觅食,有福同享。
但并不是所有寄居蟹和海葵都可以做搭档的。那就要看海葵的身体是不是符合寄居蟹的螺壳。
海葵的身体是有褶皱的,而寄居蟹的螺壳同样凹凸不平,我们可以用一个大写字母组成的字符串来表示它们的高低程度,其中A代表0,B代表1,依次类推。我们称两者相加等于25的就算是吻合,比如A和Z相吻合,B与Y吻合,依次类推。
只要海葵身体的部分序列与寄居蟹外壳的序列相吻合,就称他们可以一起生活。
阅读全文 “ACM 题目解答:寄居蟹与海葵” »

ACM 题目解答:FILE MAPPING

Description

It is often helpful for computer users to see a visual representation of the file structure on their computers. The “explorer” in Microsoft Windows is an example of such a system. Before the days of graphical user interfaces, however, such visual representations were not possible. The best that could be done was to show a static “map”of directories and files, using indentation as a guide to directory contents. For example:

ROOT
|	DIR1
|       File1
|	File2
|	File3
|	DIR2
|	DIR3
|	File1
File1
File2

This shows that the root directory contains two files and three subdirectories. The first subdirectory contains 3 files, the second is empty and the third contains one file.
阅读全文 “ACM 题目解答:FILE MAPPING” »