Monthly Archives: March 2011

ZJU 2876 解题报告

Phone List

Time Limit: 5 Seconds Memory Limit: 32768 KB

Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers:

- Emergency 911

- Alice 97 625 999

- Bob 91 12 54 26

In this case, it's not possible to call Bob, because the central would direct your call to the emergency line as soon as you had dialled the first three digits of Bob's phone number. So this list would not be consistent.

Input

The first line of input gives a single integer, 1 <= t <= 40, the number of test cases. Each test case starts with n, the number of phone numbers, on a separate line, 1 <= n <= 10000.Then follows n lines with one unique phone number on each line. A phone number is a sequence of at most ten digits.

Output

For each test case, output "YES" if the list is consistent, or "NO" otherwise.

Read more »

ZJU 2829 解题报告

Beautiful Number

Time Limit: 1 Seconds Memory Limit: 32768 KB

Mike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is dividable by 3 or 5 is beautiful number. Given you an integer N (1 <= N <= 100000), could you please tell mike the Nth beautiful number?

Input

The input consists of one or more test cases. For each test case, there is a single line containing an integer N.

Output

For each test case in the input, output the result on a line by itself.

Read more »

ZJU 2723 解题报告

Semi-Prime

Time Limit: 1 Seconds Memory Limit: 32768 KB

Prime Number Definition

An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself. For instance, 2, 11, 67, 89 are prime numbers but 8, 20, 27 are not.

Semi-Prime Number Definition

An integer greater than one is called a semi-prime number if it can be decompounded to TWO prime numbers. For example, 6 is a semi-prime number but 12 is not.

Your task is just to determinate whether a given number is a semi-prime number.

Input

There are several test cases in the input. Each case contains a single integer N (2 <= N <= 1,000,000)

Output

One line with a single integer for each case. If the number is a semi-prime number, then output "Yes", otherwise "No".

......

Read more »

ZJU 2744 解题报告

Palindromes

Time Limit: 1 Seconds Memory Limit: 32768 KB

A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.

Now give you a string S, you should count how many palindromes in any consecutive substring of S.

Input

There are several test cases in the input. Each case contains a non-empty string which has no more than 5000 characters.
Proceed to the end of file.

Output

A single line with the number of palindrome substrings for each case.

......

Read more »

我的Debian GNU/Linux——内核编译篇

距离上一篇"我的Debian GNU/Linux——安装篇"已经过去了快三个月了,本人不但很菜还很懒,加上一堆乱七八糟的考试都在年底,这篇关于内核编译的文章就一拖再拖.自己配置编译了几次内核,觉得对整个过程还是比较熟悉的.虽然对于普通用户编译内核没有多大意义.

在动手编译之前我想说Debian自带的默认内核已经包含了绝大部分配置,完全可以满足一般用户的需求,对于编译自己的内核是否有必要也是一个值得考虑的问题,编译内核是需要大量的时间(取决于您的硬件配置).如果基于以下理由,编译新内核还是很有用的:

  • 支持某些特殊的硬件,或者默认的内核配置和某些硬件冲突
  • 使用某些不为所提供的内核支持的选项
  • 通过删除无用的驱动程序来优化内核,以减少启动时间
  • 创建整体的而不是模块化的内核
  • 运行最新的内核或开发中的内核
  • 深入了解linux 内核

网络上关于编译内核基本是按照linux编译软件三步走的方式(配置,make,make install),我并不喜欢这个,软件包管理起来很不方便.按照Debian的方式编译是个很好的选择,编译结束就生成一个deb软件包,安装卸载都很容易.

......

Read more »

Debian安装配置nginx,php,mysql,wordpress教程

这段时间开始折腾VPS(Virtual Private Server 虚拟专用服务器),以前博客一直是用虚拟主机,因为我的虚拟主机所在的服务器是电信的,而我的宽带是网通的,有时上传点东西速度实在是不敢恭维,而且国内提供虚拟主机服务的公司真的是抠门到极点了,ftp连mp3都无法上传(我估计是对mp3类型的文件做了上传限制),使用过程中还经常掉线,总之是很不稳定,访问速度也不怎么样.和国外的服务相比性价比真的不怎么样.这几天正在转出域名,整个过程让我对国内的IDC服务完全失望.

我现在用的VPS主机是基于OpenVZ 技术.现在VPS用的虚拟化技术主要有Xen和OpenVZ两种.Xen是半虚拟化,基本上接近硬件环境,自由度也非常大,可以实现自定义内核配置,基于这种技术的VPS基本不用担心超卖的问题,在主机上用free -m命令查到的内存显示多少就是多少;OpenVZ 是操作系统虚拟化,效率会高一些,但会有超卖的问题,这个时候只能碰运气了,只要不是碰上无良的商家.我现在用的是小众软件的HelloHost项目提供的服务,应该是我所知道现在国内最低价的VPS服务,运行速度也不错.

用SSH连接上线后VPS用起来和真是的服务器差不多,有root权限可以自定义安装软件.只是最初的配置会比较麻烦,基本上就是自己去部署一台服务器,也算是一种锻炼吧.我现在的硬件配置如下:
256M内存
OpenVZ VPS
无交互分区
硬盘空间 15G
月流量 150G

只要稍微做一点优化,扛住200~300人同时在线一点问题也没有(估计我的网站再过几年也达不到这个级别),即使建十个八个这样的个人主页也是绰绰有余.

上网查了一些资料,我选择用nginx + php-fpm + mysql部署我的web服务器.我并不喜欢网上的那些一键安装包,我有比较强的控制欲,就像以前有个女生所我占有欲很强一样.所以部署服务器我还是喜欢一步一步自己操作.

HelloHost的VPS可供选择的操作系统有CentOS、Debain、Ubuntu、Fedora、Gentoo.我的选择Debian,因为Debian很稳定,我也比较熟悉,我自己的笔记本上装的就是Debian,相对其他几个它非常的节约内存.

......

Read more »

搞ACM的你伤不起[转载]

RoBa原创,转载请注明出处

劳资六年前开始搞ACM啊!!!!!!!!!!
从此踏上了尼玛不归路啊!!!!!!!!!!!!
谁特么跟劳资讲算法是程序设计的核心啊!!!!!!
尼玛除了面试题就没见过用算法的地方啊!!!!!!
谁再跟劳资讲算法之美算法的力量,劳资一本算法导论拍死你啊!!!!!!!!
那是搞ACM的入门书啊!!!!特么的入门书就一千多页啊!!!!!!!
还没有习题答案啊,学完了你特么都不知道自己到底会不会啊有木有!!!!!!
然后你就得看lrj的黑书啊!!!!!!还是特么的没有习题答案啊!!!!
那书难的一B啊!!!!人家一个“显然”得出的结论够你想一礼拜啊有木有!!!!
一个课后题够你想几个月啊有木有!!!!
然后还有一堆堆的书啊!!!!每一类算法都足够写一本书啊!!!!
每本都是砖头一样啊!!!!还都特么是英文的啊!!!!
也有中文翻译版啊!!!!!!翻译得跟屎一样啊!!!!
你看的时候得把它再变回英文才能懂啊!!!!!!有木有!!!!!!
......

Read more »