题目: C. From Y to Y time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output From beginning till end, this message has been waiting to be conveyed. For a given unordered multiset of n lowercase Engli…
题目链接: E. Points on Plane time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On a plane are n points (xi, yi) with integer coordinates between 0 and 106. The distance between the two points wi…
event.pageX get mouse position Description: The mouse position relative to the left edge of the document. Example <script> $(document).on( "mousemove", function( event ) { console.log( "pageX: " + event.pageX + ", pageY: &qu…
题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence . Now given n, find a permutation…
今天在程序员面试宝典上看到 int f(int x int y ) { return (x&y)+((x^y)>>1) } f(729,271) 结果为500 从式子中可以看出分为两部分 x&y和(x^y)>>1 x&y即取x,y相同位,那么也可以看做x,y相同位相加除2. (x^y)>>1即取x,y不同位除2. 之后两个相加,即相同位和不同位都除2相加的结果. 所以(x&y)+((x^y)>>1) =(x+y)/2…
高级语法 除了像上面介绍的 [x ** 2 for x in L] 这种基本语法之外,列表推导式还有一些高级的扩展. 4.1. 带有if语句 我们可以在 for 语句后面跟上一个 if 判断语句,用于过滤掉那些不满足条件的结果项. 例如,我想去除列表中所有的偶数项,保留奇数项,可以这么写: >>> L = [1, 2, 3, 4, 5, 6] >>> L = [x for x in L if x % 2 != 0] >>> L [1, 3, 5] 4.…