top

mass Framework flip插件

↘锁芯ラ 提交于 2020-02-16 00:53:45
如果浏览器支持CSS3 transform 3D的话,我们可以玩许多东西,比如flip,即电子书软件的那种翻页效果。不过,像transform3D的高级东西,不是一般浏览器能玩转,更别提IE9了。因此这时轮到JS出马了。jQuery上素以插件多出名,在上面找了几个相关插件研究一翻,搞出了自己的flip插件。总共170行。 $.define("flip", "fx", function(){ var flip = { begin: function() { var hyaline = (!"1"[0] ? "#123456" : "transparent")//透明色,IE6不支持透明,因此要使用滤镜hack一下 return {//初始化属性 hyaline: hyaline, backgroundColor: hyaline, fontSize:0, lineHeight:0, borderTopWidth:0, borderLeftWidth:0, borderRightWidth:0, borderBottomWidth:0, borderTopColor: hyaline, borderBottomColor: hyaline, borderLeftColor: hyaline, borderRightColor: hyaline, background: "none",

剑指OFFER——顺时针打印矩阵

独自空忆成欢 提交于 2020-02-15 15:52:03
输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10. class Solution { public: vector<int> printMatrix(vector<vector<int> > matrix) { int row = matrix.size(); int col = matrix[0].size(); vector<int> res; // 输入的二维数组非法,返回空的数组 if (row == 0 || col == 0) return res; // 定义四个关键变量,表示左上和右下的打印范围 int left = 0, top = 0, right = col - 1, bottom = row - 1; while (left <= right && top <= bottom) { // left to right for (int i = left; i <= right; ++i) res.push_back(matrix[top][i]); // top to bottom for (int i = top + 1; i <= bottom; +

Codechef BTREE Union on Tree

▼魔方 西西 提交于 2020-02-15 09:26:58
Link 首先可以很自然地想到把虚树建出来然后在上面搞。 我们做两遍dp,把每个点的 \(r_i\) 更新成从这个点出来能覆盖的最远距离和从其他点出来经过这个点后能够覆盖的最远距离的最大值。 这样我们保证了对于一条边 \((u,v)\) ( \(u\) 是 \(v\) 的父亲),一定存在一个点 \(w\) 使得 \(v\) 比 \(u\) 更新 \(w\) 更优。 那么我们先计算出所有更新后 \(U(x_i,r_i)\) 能够覆盖到的点的数目。 这样子肯定会算重,我们再考虑把算重的减掉。 算重的部分相当于找到上文说的那个 \(w\) ,计算有多少点在 \(w\) 上面并且被 \(v\) 的范围包含,以及在 \(w\) 下面并且被 \(u\) 的范围包含。 由 \(r_u-(dep_w-dep_u)=r_v-(dep_v-dep_w)\) 可以确定 \(w\) 的位置。 同时可以发现 \(w\) 往上往下延伸的范围是相等的,这就相当于是 \(U(w,r_u-(dep_w-dep_u))\) 。 那么我们现在需要做的就是求 \(|U(x,r)|\) 。 这个可以建出点分树然后暴力跳父亲一层层统计。 注意到 \(w\) 可能在边上,所以一开始化边为点即可。 #include<cstdio> #include<cctype> #include<vector> #include

实现顺序栈基本运算 --栈

假如想象 提交于 2020-02-15 06:23:12
C语言实现顺序栈的入栈、出栈、栈元素读取操作 1 #include <stdio.h> 2 #include <stdlib.h> 3 #define MaxSize 20 4 #define MaxNum 10 5 #define ElemType int 6 typedef struct SqStack 7 { //存储结构定义 8 ElemType elem[MaxSize]; //栈元素的存储空间 9 int top; //栈顶指针 10 }SqStack; //存储结构类型名 11 12 void Init_SqStack(SqStack *s) 13 { 14 s->top = -1; 15 } 16 17 void Push(SqStack *s,ElemType x) 18 { 19 if (s->top < MaxSize - 1) 20 { 21 s->top = s->top + 1; 22 s->elem[s->top] = x; 23 } 24 else 25 printf("栈已满,不能入栈!\n"); 26 } 27 28 int Pop(SqStack *s) 29 { 30 ElemType x; 31 if (s->top != -1) 32 { 33 x = s->elem[s->top]; 34 s->top = s->top-1; 35

215. 数组中的第K个最大元素

自闭症网瘾萝莉.ら 提交于 2020-02-15 04:48:19
215. 数组中的第K个最大元素 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 示例 1: 示例 2: 说明: 你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。 2.方法一(快速排序) 利用快速排序的思想,对数组进行递减排序,把第k大的元素放到正确的位置。 算法过程: 1.利用partition()随机获取一个元素的下标index。 2.如果index > k-1,说明第k大元素在index的左边,right = index - 1。 2.如果index < k-1,说明第k大元素在index的右边,left = index + 1。 3.当index == k-1,退出循环,返回nums[index]。 3.代码 class Solution { public : int findKthLargest ( vector < int > & nums , int k ) { int left = 0 ; int right = nums . size ( ) - 1 ; int index = partition ( nums , left , right ) ; while ( index != k - 1 ) { if ( index > k - 1 ) { right = index

利用数组或链表实现一个栈

雨燕双飞 提交于 2020-02-14 23:22:24
什么是栈 栈是一种“操作受限”的 线性表 , 只允许在一端插入和删除数据 。 栈最大的特点就是“ 后进先出 ” 栈的插入操作叫做进栈/压栈/入栈,入数据在栈顶。栈的删除操作叫做出栈。出数据也在栈顶。 顺序栈和链式栈 栈既可以用数组来实现,也可以用链表来实现。用数组实现的栈,我们叫作 顺序栈 ,用链表实现的栈,我们叫作 链式栈 。 数组实现一个顺序栈 public class ArrayStack { private String[] items; // 数组 private int count; // 栈中元素个数 private int n; //栈的大小 // 初始化数组,申请一个大小为n的数组空间 public ArrayStack(int n) { this.items = new String[n]; this.n = n; this.count = 0; } public boolean push(String item) { if(count==n){ System.out.println("栈中数据已满"); return false; } items[count]=item; ++count; return true; } public String pop() { if(count==0){ return "栈为空,删除失败"; } String tem =

41.包含min函数的栈

懵懂的女人 提交于 2020-02-14 20:43:59
class MinStack { public: /** initialize your data structure here. */ stack<int> stackValue; stack<int> stackmin; MinStack() { } void push(int x) { stackValue.push(x); if(stackmin.empty() || x <= stackmin.top()) //不要忘记单调栈为空的情况 stackmin.push(x); } void pop() { if (stackmin.top() == stackValue.top()) stackmin.pop();//删除栈顶元素时,如果单调栈符合条件,夜要删除掉 stackValue.pop(); } int top() { return stackValue.top(); } int getMin() { return stackmin.top(); } }; /** * Your MinStack object will be instantiated and called as such: * MinStack obj = new MinStack(); * obj.push(x); * obj.pop(); * int param_3 = obj.top(); *

实现网页版MQTT

a 夏天 提交于 2020-02-13 03:33:31
一、目录结构 1、目录结构 二、代码 css/index.css *{ padding: 0; margin: 0; } .left{ float: left; } .right{ float: right; } textarea{ resize: none; } #box{ overflow: hidden; width: 775px; height: 720px; /* border: 1px solid black; */ margin: 0 auto; padding: 30px 0 0 20px; box-sizing: border-box; background: #eee; } /* 连接配置开始 */ .disposition{ padding: 10px; width: 430px; height: 470px; border: 1px solid #ccc; box-sizing: border-box; position: relative; border-right: none; } .disposition li{ width: 430px; list-style: none; line-height: 60px; font-size: 20px; position: relative; } .disposition li input{ width:

区间最小值乘以区间间和

拜拜、爱过 提交于 2020-02-12 20:09:13
http://poj.org/problem?id=2796 题意:给出一个序列,求出一个子序列,使得这个序列中的最小值乘以这个序列的和的值最大。 解法:单调递增栈:每一个元素进栈前将元素剔除的过程是该元素在向左扩展,每一个元素在站内被某一元素剔除的过程为该元素的右扩展。 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <iostream> #include <string> #include <stdio.h> #include <queue> #include <stack> #include <map> #include <set> #include <string.h> #include <vector> //#include <bits/stdc++.h> #define ME(x , y) memset(x , y , sizeof(x)) #define SC scanf #define rep(i ,j , n) for(int i = j ; i < n ; i ++) #define INF 0x3f3f3f3f #define mod 1000000007 #define PI acos(-1) #define lson l,mid,root

字典相关函数(增删改查)

偶尔善良 提交于 2020-02-11 16:17:19
# ###字典的相关函数 (增删改查) # (1) 增 dictvar = {} dictvar['top'] = "凯" dictvar['middle'] = "妲己" dictvar["bottom"] = "鲁班七号" dictvar["jungle"] = "刘备" dictvar["support"] = "刘邦" print(dictvar) #fromkeys() 使用一组键和默认值创建字典 listvar = ["a","b"] dic = {}.fromkeys(listvar,None) print(dic) # 不推荐使用fromkeys ''' dic = {}.fromkeys(listvar,[]) dic['a'].append(55) print(dic['b']) ''' # (2)删除 #pop() 通过键去删除键值对 (若没有该键可设置默认值,预防报错) dictvar = {'top': '凯', 'middle': '妲己', 'bottom': '鲁班七号', 'jungle': '刘备', 'support': '刘邦'} dictvar.pop("middle") print(dictvar) # dictvar.pop("middle123") dictvar.pop("middle123","该键不存在") print