lambda表达式返回一个函数对象map(function,sequence),把sequence中的值逐个传给function,返回一个包含函数执行结果的list例子:squares=list(map(lambdax:x**2,range(10)))squares值是[0,1,4,9,16,25,36,49,64,81]相当于:squares=[x**2forxinrange(10)]也相当于:>>&g..
分类:
编程语言 时间:
2015-07-21 15:26:43
阅读次数:
144
题目请戳这里
题意:给出x1,x2,x3,x4,x5,x6,x7,x8与某值m进行异或运算后的结果,再给出x1~x8之和与m进行异或运算后的结果sum,求m.
思路:
根据位运算特性来做,由于m最大为32位,我们可以从最低位依次来推理得到,用x>>i&1来取右数第i-1位的值。
假设二进制右起第一位是1,算出所有xi的右起第一位二进制结果,累加得到tmp,比较tmp与sum的最右位,符合则...
分类:
其他好文 时间:
2015-07-20 23:47:11
阅读次数:
158
php中关于反斜线转义:php中数据的魔法引用函数 magic_quotes_gpc 或 magic_quotes_runtime 设置为on时,当数据遇到 单引号' 和 双引号" 以及 反斜线\ NULL时自动加上反斜线,进行自动转义。注释:默认情况下,PHP 指令 magic_quotes_gp...
分类:
Web程序 时间:
2015-07-18 12:23:13
阅读次数:
130
Ohana Cleans UpDescriptionOhana Matsumae is trying to clean a room, which is divided up into annbyngrid of squares. Each square is initially either cl...
分类:
其他好文 时间:
2015-07-18 10:53:19
阅读次数:
88
DescriptionSuppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The...
分类:
编程语言 时间:
2015-07-17 16:01:14
阅读次数:
105
Consider the following "magic" 3-gon ring, filled with the numbers 1 to 6, and each line adding to nine.
Working clockwise, and starting from the group of three with the numerically lowest exte...
分类:
其他好文 时间:
2015-07-17 10:06:11
阅读次数:
231
Magic Pen 6
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2057 Accepted Submission(s): 706
Problem Description
In HIT, many people...
分类:
其他好文 时间:
2015-07-16 19:45:14
阅读次数:
127
/** * 预防SQL注入攻击 * @param string $value* @return string */function check_input($value){ // 去除斜杠 if (get_magic_quotes_gpc()) { $value = strip...
分类:
数据库 时间:
2015-07-15 16:28:22
阅读次数:
142
题意:输入一个n,表示在n*n的矩阵中填1~n,使每行每列以及所有正对角线所有反对角线均出现1~n一次。若存在,输出Yes和矩阵,否则输出No;思路:比赛的时候没思路。将1~n换为0~n较好处理一些。先只考虑0的位置,每行将0向一个方向移动固定格子数,枚举所需的移动步数, 若满足条件(无同行同...
分类:
其他好文 时间:
2015-07-13 21:58:25
阅读次数:
137
在linux/unix中grep命令是非常有用的,它和管道(|)配合使用,非常强大,用于搜索文本文件,如果想要在几个文本文件中查找一字符串,可以使用‘grep’命令,‘grep’在文本中搜索指定的字符串。
假设您正在‘/usr/src/linux/Documentation’目录下搜索带字符串‘magic’的文件:
$ grep magic /usr/src/linux/Docum...
分类:
其他好文 时间:
2015-07-13 16:23:32
阅读次数:
113