摘要: A non-empty zero-indexed array A consisting of N integers is given. Thefirst covering prefixof array A is the smallest integer P such that 0≤P0:12 if a[length]:13 length-=114 else:15 break16 return length用python自带的字典来实现哈希表的功能BTW:最后得分100的感觉爽爆了 阅读全文
posted @ 2013-08-29 15:10 zsc347 阅读(562) 评论(0) 推荐(0) 编辑
摘要: You are given N round clocks.Every clock has M hands, and these hands can point to positions 1, 2, 3, ..., P (yes, these represent numbers around each face). The clocks are represented by the matrix A consisting of N rows and M columns of integers. The first row represents the hands of the first clo 阅读全文
posted @ 2013-08-23 20:10 zsc347 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 1.python的ElementTree的用法 这部分的内容主要来自对python 3.3.2的documentation的翻译 sample.xml: 1 2008 141100 4 2011 59900 68 2011 13600 从文件导入数据或者从字符串导入:import xml.etree.ElementTree as ETtre... 阅读全文
posted @ 2013-08-22 18:13 zsc347 阅读(596) 评论(0) 推荐(0) 编辑
摘要: 1.针对接口编程 接口是一系列方法的声明,是一些方法特征的集合,一个接口只有方法的特征没有方法的实现. 接口是对抽象的抽象 针对接口编程也称为面向接口编程,将设计和实现分开,使用时只需引用借口即可,用于系统各部分的解耦合.2.单一职责原则 定义:一个类的功能要单一,只做与它相关的事情. 遵循单一职责原则会给测试带来极大的方便. 违背单一职责原则会降低类的内聚性,增强类的耦合性.3.开放封闭原则 定义:一个软件实体应当对扩展开放,对修改关闭.开放封闭原则是面向对象原则的核心. 封装变化,以来接口和抽象类,而不要依赖具体实现类.要针对接口和抽象类编程,不要针对具体实现编程. 我们无法控制变化,但我 阅读全文
posted @ 2013-08-20 15:39 zsc347 阅读(201) 评论(0) 推荐(0) 编辑
摘要: python处理xml报错:xml.etree.ElementTree.ParseError: not well-formed (invalid token):查询得知xml有不支持的字符范围出现这个错误的原因是,xml文件中含有非法字符,是一个bad xml,即不符合xml规范的.由于xml文件是第三方提供,只能自己这里处理掉xml中的非法字符python过滤方法: text=open("badxml.xml").read() text=re.sub(u"[\x00-\x08\x0b-\x0c\x0e-\x1f]+",u"",tex 阅读全文
posted @ 2013-08-13 19:46 zsc347 阅读(16132) 评论(0) 推荐(1) 编辑
摘要: 问题描述:guest系统为winxp ,主机为ubuntu 12.04qemu-system-i386 5g256mxpsp2.qcow2 -m 256 -net nic,nodel=rtl8139 -net user-rtc clock=vm启动镜像之后,xp系统开机运行良好monitor输入savevm test,然后loadvm之后系统处于死机态,monitor输入sendkey ctrl-alt-delete无法重启,可以用system-reset重启,鼠标键盘都处于无法输入状态问题解决:qemu-system-i386 5g256mxpsp2.qcow2 -m 256 -net ni 阅读全文
posted @ 2013-07-23 13:30 zsc347 阅读(413) 评论(0) 推荐(0) 编辑
摘要: 一:基本使用1.创建镜像eg:qemu-img create -f raw xp.raw 8G命令格式:qemu-img create [-q] [-f fmt][-o options] filename [size]2.启动虚拟机,指定安装镜像文件eg:qemu-system-i386 xp.raw -boot d -cdrom xp.iso -m 512-boot d:从光驱启动-cdrom xp.iso:制定光驱镜像文件-m 512:指定内存大小为512M命令格式:qemu-system-i386 [options] [disk_image]3.增大(减少)镜像文件大小eg:qemu-i 阅读全文
posted @ 2013-07-19 14:36 zsc347 阅读(1418) 评论(0) 推荐(1) 编辑