自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(152)
  • 收藏
  • 关注

原创 Webpack 之 jQuery

当我们运用Webpack前端打包工具以及Npm做包管理工具时候,如何运用引入jQuery插件呢? 主要问题是各种插件用$, jquery,jQuery,windows.jQuery等,这些无法明确,最终导致build的时候出现 xxx is not defined的错误。ProvidePlugin 先介绍个插件:自动加载模块。 功能: new webpack.Prov...

2018-07-31 00:46:13 720

原创 分布式任务解决方案

背景 在业务开发过程中,你可能会碰到有任务形式的场景。比如Client请求Proxy GateWay(同时后端有若干机器), 要求执行某个(执行时间不定)的任务。如何去保证任务被执行一次。或者你的第一反应是,根据请求参数Hash取模似的统一请求只打到特定机器,但是如上场景明显不能做到,因为Proxy不受你控制。下面提供两种可行,简单的方式。 a. MySQL行锁(FOR UPDATE)...

2018-03-27 11:37:01 500

原创 Golang-Json标准包

Json Tag的妙用(-、omitempty、string、number)package golangimport ( "encoding/json" "fmt" "log" "testing")type Product struct { Name string `json:"name"` Desc stri...

2018-03-14 22:23:45 1630

原创 11.28 北京,念腾讯暑假,不思则惘吧!

书单,计划

2016-11-28 00:24:09 419

原创 网易

#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <set>#include <queue>using namespace std;int ls,rs;int arr[100010];int ...

2016-09-12 20:44:30 512

原创 Programming Collective Intelligence

What is Collective Intelligence?What is Machine Learing?机器学习是人工智能(AI,artificial intelligence)领域中与算法相关的一个子域,他允许计算机不断地进行学习。大多数情况下,这相当于将一组数据传递给算法,并由算法推断出与这些数据的属性相关信息-----借助这些信息,算法就能够预测出未来有可能会出现的其他数

2016-05-07 11:59:01 751

原创 [递推+dfs]ZOJ 3436. July Number

题目大意:        将一个数字的相邻两位的差(的绝对值)组成一个新的数字,不断重复,如果最后得到7,就称这个数为July Number,比如9024 – 922 – 70 – 7。题目要求1e9范围内给定区间[a, b]里July Number的个数。思路:逆向递推,既然题目求能化成 7 的数的个数,那么就从 7 逆着找出去 18 ,29,70,81,92等,(要注意的就是:还有

2015-07-27 13:55:45 844

原创 Codeforces Round #313 (Div. 2)

C. Gerald's Hexagon题目大意:给定一个六边形,边长a1,a2,a3,a4,a5,a6,各内角是120°,且整数边长,求用平行边的线能分割成多少个边长为 1 的三角形;思路:N边形一定是很规则的(由上条件,画图可知),见下图,整个补全,会是正三角形,分割数数(a1+a2+a3)^2,再减三个角多余的三个三角形(a1^2+a3^2+a5^2)代码:http://c

2015-07-27 13:48:29 594

原创 UESTC 1091秋实大哥の恋爱物语 [偏移模式匹配]

题目链接:http://acm.uestc.edu.cn/#/problem/show/1091题目大意:求模式串p,在s中出现的次数,但是p能平移到s即可,比如s: 1 3 4和 p :0 2 3;题目思路:处理出每一位相对前一位的变化,然后KMP即可;代码://author:ACsorry//result:Yes#include#include#include#i

2015-05-15 00:10:14 900

原创 POJ - 1094 Sorting It All Out [ topo]

Sorting It All OutDescriptionAn ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest. For examp

2015-05-07 01:08:08 553

原创 Race to 1 Again [概率]

题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=76505#problem/C题目大意:给一个数n,从n随机选一个【1,n】的约数除,然后得到新n,反复操作直到n等于1,求操作次数的期望;题目分析:期望dp: 对于期望往往是倒着求,dp[ i ]表示i->1的期望次数,必然是dp[ 1 ]=0,这是最终状态,然后

2015-05-05 00:41:06 772

原创 lightoj 1030 Discovering Gold[ 期望 ]

B - Discovering GoldDescriptionYou are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold.Initially you are in positi

2015-05-04 23:53:50 689

原创 ZOJ - 2107 Quoit Design [分治]

题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=17751题目描述:求最近点对题目分析:分治,(nlogn);为什么,第二轮按排序:http://noalgo.info/793.html代码://problem: zoj 2107 Quoit Design//author: A

2015-05-04 21:14:07 594

原创 CF 148D. Bag of mice[概率dp]

题目链接:http://codeforces.com/problemset/problem/148/D题目大意:一袋子里有w个白老鼠,b个黑老鼠;A和B轮流抓老鼠(不放回),谁先抓到白老鼠,谁win;因为B粗鲁,每次抓完一只老鼠,会跑出来一只;A first;            求A win的概率;题目分析:此类概率dp的状态比较固定,dp(i , j )表示当前状态Awin的

2015-05-01 23:54:55 537

原创 cf 301 div2

A - Combination Lock 题目大意:给有n个(0-9)环圈密码锁,数串 s1->s2最少移动次数;题目分析:简单模拟;代码:const int N=100007;char s1[N],s2[N];int main(){ int n; while(scanf("%d",&n)==1) { int ans=0;

2015-05-01 10:58:56 744

原创 HYSBZ 1588 营业额统计spaly入门]

题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26185题目大意:依次插入n个数,求当前插入数与之前数的最小差,并sum每次插入得到的最小差;题目分析:splay,就是对数的维护。STL set一样做。资料:http://blog.csdn.net/ACM_cxlove/article/deta

2015-04-30 23:24:45 799

原创 POJ 3264 Balanced Lineup[RMQ入门题]

题目链接:http://poj.org/problem?id=3264题目大意:n个数,求区间[ L,R ]的最大最小值之差;题目分析:RQM:dp[ i ][ j ], i开始长度为2^j的长度的区间最值;O(nlog n)的预处理区间值,O(1)的查询;代码://author: ACsorry//result: accept#include#inclu

2015-04-28 20:40:06 575

原创 HDU 2222 Keywords Search[自动机]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2222题目大意:给n个模板串,求长串中模板串的个数;解题思路:       自动机入门题,注意模板重复串。代码:#include#include#include#include#include#include#include#include#include

2015-04-25 23:00:06 458

原创 poj 3693 Maximum repetition substring(08合肥 RMQ+后缀数组)

传送门:http://poj.org/problem?id=3693题目:给出一个串,求重复次数最多的连续重复子串;分析:枚举重复单元的长度,然后理所当然的枚举起点。利用rmq处理,后缀i,i+l的最长前缀。lcp/l+1,为当前相邻l长度单元的串的重复次数,但是由于i+=l,提高了效率,但是i不一定刚好是重复串的起点,所以如果r%l!=0,把串往前移l-r%l个单位。找到

2015-04-22 00:27:16 674

原创 HDU 3555 Bomb [数位]

DescriptionThe counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If the current numb

2015-04-14 22:07:57 494

原创 codeforces 55D Beautiful numbers[数位dp]

D. Beautiful numberstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVolodya is an odd boy and his taste is

2015-04-14 20:51:31 666

原创 Codeforces 385C Bear and Prime Numbers [素数筛法]

Code:#include#include#include#include#include#include#include#include#include#include#include#include#define INF 0x7fffffff#define SUP 0x80000000#define mem(a,b) memset(a,b,sizeof(a)

2015-04-14 00:20:09 1201

原创 vijos 1404 遭遇战[spfa]

传送门:https://vijos.org/p/1404Analyse:题目给一些区间,要求是找some区间,使得所选区间并集包含题目【s,e】,且权值和最小。*加上 (i)->(i-1) 权值为0的边。*每边为s->e+1,,刚好是区间连起来Code:#include#include#include#include#include#include#in

2015-04-13 18:49:27 868

原创 BZoj 1293 生日礼物(小顶堆)

传送门:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=27400Anayse:小顶堆;1 1 5     - >    1 3 5     ->    3 5 7    ->     5 7 8pop(1)    p(1)      p(3)       最优解。每次剔除堆顶,然后换push与

2015-04-13 14:41:19 651

原创 poj 2481 Cows[求逆序数]

COWsDescriptionFarmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good.

2015-04-02 17:46:47 547

原创 HYSBZ 1406 密码箱【数学】

Description在一次偶然的情况下,小可可得到了一个密码箱,听说里面藏着一份古代流传下来的藏宝图,只要能破解密码就能打开箱子,而箱子背面刻着的古代图标,就是对密码的提示。经过艰苦的破译,小可可发现,这些图标表示一个数以及这个数与密码的关系。假设这个数是n,密码为x,那么可以得到如下表述: 密码x大于等于0,且小于n,而x的平方除以n,得到的余数为1。 小可可知道满足上述条件的x可能不

2015-04-02 14:42:44 775

原创 cf 398B. Painting The Wall【期望dp】

传送门:http://codeforces.com/problemset/problem/398/BDescription:User ainta decided to paint a wall. The wall consists of n2 tiles, that are arranged in an n × n table. Some tiles are painted

2015-04-02 14:33:39 727

原创 HDU 2089 不要62【数位板】

Description:不吉利的数字为所有含有4或62的号码。输出n-m之间的吉利数的个数!Analyse:数位dp的原理:如果A对于数位dp板,重点是参数的设置!CODE:#include#include#include#include#include#include#include#include#include#include#include

2015-04-01 09:06:47 667

原创 广东工业大学2015新生赛round2(//自己脑洞堵了,madan!)

Path:新生赛A.Number SequenceDescription:A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculat

2015-04-01 07:34:45 840

原创 uva 674 Coin Change【背包】

Brief Description:there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.n元找零,求找法。Analyse:背包问

2015-03-30 17:40:07 426

原创 uva 103/UVA 10405 [lcs]

uva103:题目给的是第i个的排位。CODE:#include#include#include#include#include#include#include#include#include#include#include#include#define INF 0x7fffffff#define SUP 0x80000000#define mem(a,b) m

2015-03-30 17:35:02 399

原创 UVA 111 History Grading 【lcs】

Brief Description:一个历史考试,有n个历史事件, 它们之间的年份是不同的,要学生把这些事件按照正确的顺序排列出来。有两种记分方式,采用的是第二种: 假设有历史事件1,2,3,4, 它们正确的时间顺序是1,2,3,4, 然后假设学生的答案是1,3,2,4, 那么按照相对顺序正确的数量,答对了三个(1,2,4或者1,3,4),也就是它与正确答案的最长公共子序列长度是3,便是答

2015-03-30 12:36:36 624

原创 bzoj3208 花神的秒题计划Ⅰ 【记忆化】

Description背景【backboard】: Memphis等一群蒟蒻出题中,花神凑过来秒题……描述【discribe】: 花花山峰峦起伏,峰顶常年被雪,Memphis打算帮花花山风景区的人员开发一个滑雪项目。 我们可以把风景区看作一个n*n的地图,每个点有它的初始高度,滑雪只能从高处往低处滑【严格大于】。但是由于地势经常变动【比如雪崩、滑坡】,高度经常变化;同时,政

2015-03-30 11:16:19 713

原创 bzoj 1962 模型王子 【猜数问题】

Brief description :猜数问题:有一个被猜数X,是1到N的范围内的整数,你每次可以给出一个整数Y。你会在你问下一个问题之后得到你这个问题的回答,即X与Y的大小关系。并且如果你得到了K次XAnalyse:f[i][j],表示i次猜数,j次X友链:猜数问题研究论文CODE:#include#include#include#include#includ

2015-03-30 10:55:21 890

原创 baoj1875 HH去散步 【矩阵转移】

Brief description :给定一个可能重边但没有自环的无向图,要求计算 A, B 两点之间步数为 t 的方案数。答案模 45989。(可以经过某个点某条边多次,但是不可以立即沿着同一条边折返。)(.. N Analyse :由于“不会沿着同一条边折返”,因此从 A 点经过 k 步後的状态仅与最后一步所走的边和它的方向有关。如果将每条无向边拆成两条有向边,那么

2015-03-30 09:56:42 744

原创 hdu 4418 Time travel [gause+dp]

Time travelTime Limit:1000MS    Memory Limit:32768KB    64bit IO Format:%I64d & %I64uAgent K is one of the greatest agents in a secret organization called Men in Black. Once he needs t

2015-03-25 22:23:10 662

原创 hdu 4336 Card Collector[期望]

Card CollectorTime Limit:1000MS    Memory Limit:32768KB    64bit IO Format:%I64d & %I64uDescriptionIn your childhood, do you crazy for collecting the beautiful cards in the snacks? They sa

2015-03-25 09:35:59 658

原创 poj 3774 Scout YYF I (矩阵优化的概率DP)

题意: n个雷,分别在a[1]...a[n] ,走一步概率为 p ,走两步概率为 1-p ,一开始在 1 号位置,问安全到达终点的概率。思路:将整个过程划分成阶段处理:1 ~ a[1]a[1]+1 ~ a[2]…………a[n-1]+1 ~ a[n]那么只要求出每次踩到雷的概率,求反面,再把所有阶段结果连乘就可以了。ans[i]表示踩中i的概率,那么可推倒出 ans[

2015-03-24 19:24:34 553

原创 hdu 1520 Anniversary party[树形dp]

http://acm.hdu.edu.cn/showproblem.php?pid=1520代码:#include#include#include#include#include#include#include#include#include#include#include#include#define INF 0x7fffffff#define SUP

2015-03-23 16:39:37 504

原创 codeforces 520B Two Buttons[记忆化搜索]

传送门:http://codeforces.com/contest/520/problem/BB. Two ButtonsVasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing s

2015-03-12 18:50:48 777

空空如也

空空如也

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

TA关注的人

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