自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

一只特立独行的猪

记录前端学习的点滴

  • 博客(68)
  • 资源 (2)
  • 收藏
  • 关注

原创 Rotate Array

题目如下:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].第一种方法:var rotate = function(nums

2015-03-25 17:04:42 683

原创 Reverse Bits

题目如下:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as0

2015-03-25 15:40:53 544

原创 让div水平和垂直居中

1.css样式实现 #demo { position: absolute; width: 200px; height: 200px; left: 50%; top: 50%; margin: -100px 0 0 -100px; background: #5BBF5A; }

2015-03-24 21:06:02 937

原创 javascript创建对象总结(javascript高级程序设计)

1.工厂模式这种模式抽象创建具体对象的过程,用函数封装特定的接口来创建类。 function createStudent(name) { var o = new Object(); o.name = name; o.sayName = function() { alert(this.name); };

2015-03-19 16:49:06 789

原创 ajax学习笔记

1.创建XMLHttpRequest对象 var request; if (window.XMLHttpRequest) { request = new XMLHttpRequest();//IE7, Firefox, Chrome, Opera, Safari } else { request = new ActiveXObject("Microsoft.XMLHTTP")

2015-03-18 22:46:03 796

翻译 CSS工具之CSS重置(Reset CSS)

重置样式表的目的是减少不同浏览器在默认样式中的不一致性,比如line-height,margin和标题的font-size等等  下面给出的重置样式故意写的很普通。比如,没有给body元素设置默认的color和background。我不推荐你在没有加工如下代码的情况下,就把它应用到你的项目中。它需要进行调整,加工,扩充然后转变成适合你自己特定的CSS重置标准。比如,给网页和链接添加你喜欢的颜色

2015-03-08 22:01:39 705

原创 外边距叠加

1.什么是外边距叠加?  在css中,两个和更多盒模型的相邻外边距将形成一个外边距,这个外边距的高度等于发生叠加的外边距中较大的一个。外边距的这种组合方式称为叠加,这样组合的外边距叫做叠加外边距。只有普通文档流中的块框的垂直外边距才会发生外边距叠加,行内框,浮动框或绝对定位框之间的  外边距不会叠加。2.外边距叠加的几种基本情形  (1)相邻元素    相邻的外边距会发

2015-03-07 17:29:37 732

原创 学习css中的文档流

1.我们来理解什么是文档流?      官方文档中有这样一句话:The flow of an element A is the set consisting of A and all in-flow elements whose nearest out-of-flow ancestor is A。翻译过来大概是这样,A元素的文档流是一个集合,这个集合由A和所有流内元素组成,并且这些流内元素的最

2015-03-05 23:18:58 838

原创 node.js搭建一个简单的电影网站

一直都想学习node.js,但都没有下手。这几天终于有时间把慕课网的node+mongodb建站攻略的视频学习了一遍。收获还是蛮大的,记录一下自己的成果: 最后附上自己的源码:https://github.com/superpig/Imovie点击打开链接

2015-02-06 00:05:04 6282 3

原创 CSS绘制三角形的原理剖析

今天学习Bootstrap时候,看到按钮的向下三角形源码:.caret { display: inline-block; width: 0; height: 0; margin-left: 2px; vertical-align: middle; border-top: 4px solid; border-right: 4px solid transparent

2015-01-23 12:14:26 7848 1

原创 uva 133

还是约瑟夫问题#include #include #include using namespace std;const int maxn = 25;int num[maxn];int flag[maxn];int main(){ int n,k,m; while(~scanf("%d %d %d",&n,&k,&m) && n && k && m) {

2013-09-03 18:08:25 747

原创 poj 3750

约瑟夫问题#include #include #include const int maxn = 55;const int maxl = 20;using namespace std;char name[maxn][maxl];bool flag[maxn];int main(){ int n; while(~scanf("%d",&n)

2013-09-03 16:39:33 847

原创 sgu 112

import java.io.*;import java.util.*;import java.math.*;public class Solution{ public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigD

2013-08-29 10:58:14 603

原创 uva 10523

import java.io.*;import java.util.*;import java.math.*;public class Main{ public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); while(cin.hasN

2013-08-29 10:16:29 708

原创 poj 2305

import java.io.*;import java.util.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int bas

2013-08-29 09:53:19 640

原创 poj 1604

java做的,特么慢.import java.util.*;import java.io.BufferedInputStream;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputS

2013-08-28 11:09:48 736

原创 poj 1405

递推公式 Xn = Xn-1 * (Xn-1 - 1)  + 1;import java.util.*;import java.io.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new Buffer

2013-08-28 10:13:09 745

原创 poj 1131

import java.util.*;import java.io.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigDecimal ei

2013-08-27 17:03:03 656

原创 poj 1503

import java.util.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger a = BigInteger.ZERO; BigInteger sum =

2013-08-27 12:00:54 552

原创 poj 1001

用Java高精度计算的题实在太简单了.import java.util.*;import java.math.*;public class Main { public static void main(String[] args) { Scanner aa = new Scanner(System.in); while(aa.hasNext()){

2013-08-27 11:21:54 585

原创 ACM之java速成

转载于http://hi.baidu.com/czyuan_acm/item/2c115f6b3d35192469105bae 这里指的java速成,只限于java语法,包括输入输出,运算处理,字符串和高精度的处理,进制之间的转换等,能解决OJ上的一些高精度题目。1. 输入:格式为:Scanner cin = new Scanner (new BufferedInputStream

2013-08-27 11:11:58 794

原创 hdu 1241

简单的广搜题目,一次AC.#include #include #include #include using namespace std;struct node{ int x,y;};const int maxn = 105;char map[maxn][maxn];bool vis[maxn][maxn];int row,col;int d

2013-08-26 15:29:27 537

原创 hdu 1072

因为0#include #include #include #include const int maxn = 10;using namespace std;struct node{ int x,y; int time; int ans;};int dir[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};int map[maxn][m

2013-08-25 22:09:44 825

原创 uva10285

#include #include #include using namespace std;const int maxn = 110;int row,col;int map[maxn][maxn];int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};int res[maxn][maxn];int research(int r,

2013-08-25 09:48:58 596

原创 hdu 1114

完全背包简单题.#include #include #include #include #define inf (1 << 30)using namespace std;const int maxn = 10000;int dp[maxn];int val[510],weit[510];int main(){ int cas; sca

2013-08-22 22:10:57 685

原创 uva 10465

完全背包问题,只是物品只有两件既吃汉堡包的时间,容量为总时间t,每个物品的价值为1.#include #include #include using namespace std;const int maxn = 10010;int dp[maxn];int main(){ int t,p[3]; while(~scanf("%d %d %d",&p[

2013-08-22 17:24:32 623

原创 hdu 3496

初始化的细节问题我们看到的求最优解的背包问题题目中,事实上有两种不太相同的问法。有的题目要求“恰好装满背包”时的最优解,有的题目则并没有要求必须把背包装满。一种区别这两种问法的实现方法是在初始化的时候有所不同。如果是第一种问法,要求恰好装满背包,那么在初始化时除了f[0]为0其它f[1..V]均设为-∞,这样就可以保证最终得到的f[N]是一种恰好装满背包的最优解。如果并没有要求必须把背

2013-08-22 15:28:28 632

转载 背包问题

01背包问题描述:01背包(ZeroOnePack):有N件物品和一个容量为V的背包,每种物品均只有一件。且每i件物品的重量为weight[i],价值为value[i]。求解将哪些物品装入背包可使这些物品的重量总和不超过背包容量,且价值总和最大。 背包特点:每种物品仅有一件,可以选择放或不放。 基本思路:用子问题定义状态:即DP[i][v]表示前i件物品恰好放入容量

2013-08-22 10:38:24 662

原创 uva 357

#include #include #include const int maxn = 30010;using namespace std;int cent[6]={0,1,5,10,25,50};long long dp[maxn];int main(){ int n; while(~scanf("%d",&n)){ for

2013-08-21 19:40:55 734

原创 uva 10192

又是一道水题,最长公共子序列。#include #include #include #include using namespace std;const int maxn = 110;int dp[maxn][maxn];int main(){ string str1,str2; int cas = 1; while(getline

2013-08-21 18:49:18 553

原创 uva 10130

01背包问题,开始有点犹豫能不能拿同一样物品,觉得有点复杂。后来发现可以拿同一件物。#include #include #include using namespace std;const int maxn = 1010;int w[maxn],val[maxn],dp[maxn];int g[105];int main(){ int cas;

2013-08-21 17:18:20 549

原创 uva 10066

简单的模板题,最长公子序列。#include #include #include #include using namespace std;const int maxn = 105;int dp[maxn][maxn];int a[maxn],b[maxn];int main(){ int cas = 1; int n1,n2;

2013-08-21 15:28:35 709

原创 poj 2576

背包问题,二维的dp.#include #include #include using namespace std;const int maxn = 110;const int maxw = 45010;int num[maxn];bool dp[maxn][maxw];int main(){ int m; while(~scanf("%d",&m)){

2013-08-21 14:50:10 685

原创 uva 562

01背包问题,列举所有的分配可能,然后求两人钱相差最少的值。 #include #include #include using namespace std;const int maxn = 105;const int maxm = 50005;bool dp[maxm];int cent[maxn];int main(){ int cas;

2013-08-21 10:39:58 722

原创 uva 10131

题意:给你许多大象的体重和IQ值,证明大象越重,智商越高的结论是错误的.把大象的体重按照升序排列,然后找IQ序列中的最长递减序列.#include #include #include #include #include using namespace std;const int maxn = 1010;struct pnt{ int wet;//体重

2013-08-20 23:57:04 526

转载 求最长单调递减子序列

问题描述:求一个数组的最长递减子序列 比如{9,4,3,2,5,4,3,2}的最长递减子序列为{9,5,4,3,2}。      思路:这是很经典的一个问题,用动态规划解决。假设源数组为A,定义一个辅助数组为B,B[i]表示以A[i]结尾的最长递减序列的长度。举个简单的例子,如果A[i]大于之前的所有元素,那么B[i] = 1。      有了这个辅助数组后,可以推出下

2013-08-20 15:41:49 1186

原创 uva 674

状态方程为dp[j] = dp[j] + dp[j -cent[i]];#include #include const int maxn = 7500;using namespace std;int dp[maxn];int cent[6] = {0,1,5,10,25,50};int main(){ int n; while(~scanf(

2013-08-20 13:59:12 817

原创 hdu 1950

1.学习了最长上升子序列nlogn算法在川大oj上遇到一道题无法用n^2过于是,各种纠结,最后习得nlogn的算法最长递增子序列,Longest Increasing Subsequence 下面我们简记为 LIS。排序+LCS算法 以及 DP算法就忽略了,这两个太容易理解了。假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5。

2013-08-20 11:20:56 581

原创 uva 10714

#include #include #include using namespace std;int main(){ int cas; scanf("%d",&cas); while(cas--) { int len,m,d; int Min,Max; Max = Min = -1; sca

2013-08-19 22:25:21 601

原创 uva 10720

Havel-Hakimi定理#include #include #include #include const int maxn = 10010;using namespace std;int deg[maxn];bool Cmp(int x,int y){ return x > y;}bool Havel_Hakimi(int n){ for(int

2013-08-19 20:48:24 490

算法艺术与信息学竞赛题目完全解析

算法艺术与信息学竞赛题目完全解析是一本非常不错的题集,里面还有源代码.

2013-07-26

算法导论全套资料

算法导论第二版及其答案,如果你要学算法,这是你必须拥有的一本书.

2013-07-26

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除