- 博客(77)
- 收藏
- 关注
原创 Python 微服务开发中常用的Docker 模板
FROM ubuntu:18.04ENV TZ Asia/ShanghaiRUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \ apt-get update && \ ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &.
2020-07-20 10:39:21
405
原创 动态规划入门之从递推到状态转移
在了解动态规划前,不妨先看看题目http://acm.hdu.edu.cn/showproblem.php?pid=2046。截图如下.问你当n为任意数(n>0)时, 骨牌的铺放方案有几种?咱可以先从归纳法试试,列举出可能出现的解。当n=1时,只有一种铺放方案,即 |当n=2时,有两种方案,即 || 或 =当n=3时,有||| ,|= ,=| 当n=4时,有||||, |=|, =||, ||=, ==当n=5时,有。。。8种,我不写了。。看...
2020-07-17 18:01:03
519
原创 Python queue源码解析,如何写线程安全的队列
python 的队列实现方式很简单,通过互斥锁+条件变量的方式实现,这种方式实在是太经典了。最近看的《现代操作系统》中,在线程通信的互斥量一节就有提及互斥量+条件变量来解决生产者消费者问题。(参见《现代操作系统》第4版P76-P77)互斥量,不必多说,如python中的threading.lock(),也就是我们最常用的锁。它限制了同一个时刻,只能有一个线程进入临界区中,保证了临界区的线程安全...
2020-06-29 22:42:58
780
原创 ubuntu 安装NVIDIA驱动 cuda NVIDIA-docker
1.安装NVIDIA驱动 sudo add-apt-repository ppa:graphics-drivers/ppaaudo apt-get updatesudo apt-get install nvidia-390 检测驱动安装状态: nvidia-smi 如果出现如下类似相关输出,表示成功。2.安装cuda9.02.1安装...
2019-04-08 11:40:41
861
原创 ssh端口转发,打洞
老焦有一个腾讯云的主机,每个月10块钱,配置很低的那种,但是优点是有个外网ip,想在哪使用就在哪使用。 老焦还有个性能很叼的机器,可惜外网不能使用,老焦可以利用这个腾讯云的ecs去转发请求来登录内网机器。1.服务端设置先在腾讯云的/etc/ssh/sshd_config添加以下四项:AllowAgentForwarding yesAllowTcpForwardin...
2018-11-21 15:39:32
979
原创 gitlab CI/CD环境搭建
1.安装gitlab-runner# Linux x86-64sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64sudo chmod +x /usr/local/bin/gi...
2018-09-05 15:23:05
2359
原创 hihocoder-1116 : 计算 (线段树区间合并)
描述现在有一个有n个元素的数组a1, a2, ..., an。记f(i, j) = ai * ai+1 * ... * aj。初始时,a1 = a2 = ... = an = 0,每次我会修改一个ai的值,你需要实时反馈给我 ∑1 f(i, j)的值 mod 10007。输入第一行包含两个数n(1接下来q行,每行包含两个数i, x,代表我把ai的值改为了
2017-09-30 10:24:28
280
原创 hihocoder 1591 - 锦标赛(费用流)
思路:拆点,每个点拆成两个,限流的不用多说了吧。然后,关键在于某点A和B有边,但是实际结果只能二选一,怎么办呢?弄一个辅助点C加边方式(A’,C,1,-SC[A][B]), (B',C,1,-SC[B][A]), (C,C', 1, 0), (C',T, INF, 0); //(U,V,CAP,COST)代码:#include #include #include #inclu
2017-09-28 21:22:59
296
原创 将csv导入到mysql数据表中
看了网上的很多代码,试了很多都没用。所以决定自己写个。实例:load data local infile "E:/book1.csv" into table `monster`.`c_monstermodel` character set GBK fields terminated by ',' enclosed by '"' lines terminated by '\r\n';"E:/
2017-07-11 19:19:34
2621
原创 51nod-1086 多重背包
#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define LL long long#define lson l,m,rt<<1#define rson m+1,r,rt<<1|
2017-06-03 20:47:09
328
原创 SPOJ - GSS4 Can you answer these queries IV
这种题做的多了,套路一下就好,只是。。。#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define LL long long#define lson l,m,rt<<1#de
2017-05-08 20:36:32
364
原创 poj 2104(主席树)
这是我的第一道主席树,感谢http://www.cnblogs.com/zyf0163/p/4749042.html的教程#include #include #include #include #include #include #include #include #include #include #include using namespace std;#d
2017-05-02 20:10:05
281
原创 LightOJ - 1086
思路:欧拉回路中所有点的度为偶数,然后剩下奇数的点用状压DP找最短路即可。#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define LL long long#define l
2017-04-17 11:37:07
318
原创 UESTC - 482 Charitable Exchange(线段树)
题意:一开始明星有一块钱,他把一块钱拿去换其他价值的东西使得最后价值大于M并时间最短,无解输出-1.思路:按照需求R升序排序,并且按照可达价值作为下标,所用时间作为值进行线段树建树。#include #include #include #include #include #include #include #include #include #include #incl
2017-04-12 14:23:24
368
原创 zoj 3956-Course Selection System(背包)
Course Selection SystemTime Limit: 1 Second Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. Thei-th course is described by two values:
2017-04-09 20:38:48
363
原创 zoj3950-How Many Nines
How Many NinesTime Limit: 1 Second Memory Limit: 65536 KB If we represent a date in the format YYYY-MM-DD (for example, 2017-04-09), do you know how many 9s will appear in all the dates
2017-04-09 20:34:41
288
原创 fzu-2116 买糖果(背包)
递推方程:dp[i+1][j+y] = max(dp[i+1][j+y],dp[i][j]+x); dp[i][j] 中 i 表示选了 i 个糖果罐中有第二种糖果 j 个。时间复杂度为O(n^3).#include #include #include #include using namespace std;int dp[105][1005];int main(){
2017-04-06 18:50:16
495
原创 hdu 5700 区间交(线段树)
好久没做这种题都不太会了。想法是先排序然后就大概有个方向了。#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define LL long long#define lson l,m
2017-04-01 20:27:51
315
原创 codeforces-487B Strip(dp+rmq+二分+水数据)
笑死,最坏情况下时间复杂度为O(n*nlogn)思路:每次找前面最小l,使[l,i]满足条件,dp[i] = dp[l-1]+1;#include #include #include #include #include #include #include #include #include #include #include using namespace s
2017-03-27 21:00:30
447
原创 codeforces 787a
听说这其实就是一道水题,我硬生生用了数论方法来解,真是caonima#include #include #include #include #include #include #include #include #include #include #include using namespace std;#define LL long long#define
2017-03-25 19:07:11
883
原创 FZU 2120-数字排列(状压DP)
S得到了一个数,他认为相邻位上的数字与数字之间会产生不良影响,比如123,1和2之间产生一个不良影响值,2和3之间产生一个不良影响值。现在他想调整这个数每位的数字的顺序,使得最终得到的数的总的不良影响值最小,且没有前导0。Input输入数据的第一行为T表示有T组数据。每组数据先输入一个整数n(0Output对于每组数据输出一行一个数,表示最小的不良影响值。
2017-03-21 16:48:02
322
原创 zoj 3686 - A Simple Tree Problem (dfs序+线段树区间更新)
Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0.We define this kind of operation: given a subtree, negate all its labels.And we want to query t
2017-03-20 18:30:53
286
原创 Fzu 2234 牧场物语(DP)
Problem 2234 牧场物语Accept: 148 Submit: 722Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description小茗同学正在玩牧场物语。该游戏的地图可看成一个边长为n的正方形。小茗同学突然心血来潮要去砍树,然而,斧头在小茗的右下方。小茗是个讲究效
2017-03-17 11:30:28
828
原创 FZU - 2128 最长子串(KMP?)
问题很简单,给你一个字符串s,问s的子串中不包含s1,s2...sn的最长串有多长。Input输入包含多组数据。第一行为字符串s,字符串s的长度1到10^6次方,第二行是字符串s不能包含的子串个数n,n字符串由小写的英文字符组成。Output最长子串的长度Sample Inputlgcstraightlalongahisnstreet5strl
2017-03-14 19:46:23
318
原创 FZU-2218 Simple String Problem(状压DP)
Problem DescriptionRecently, you have found your interest in string theory. Here is an interesting question about strings.You are given a string S of length n consisting of the first k lowercase
2017-03-14 19:43:59
401
原创 FZU-2172 DP
大师兄在取经途中迷上了ACM-ICPC,稍不留神,师傅就被妖怪抓走了。 大师兄并不着急去救师傅,在虐这道简单题: 有两个字符串A和B,每一次可以选择以下操作中的一种,只对字符串A进行操作,用最少的操作使得字符串A与字符串B相等:在字符串A中插入一个字符;在字符串A中删除一个字符;将字符串A复制,得到字符串A的一个拷贝C,将字符串C接在字符串A后面。Input
2017-03-13 20:19:54
306
原创 BZOJ-2038 小Z的袜子(hose) (莫队算法)
作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿。终于有一天,小Z再也无法忍受这恼人的找袜子过程,于是他决定听天由命……具体来说,小Z把这N只袜子从1到N编号,然后从编号L到R(L 尽管小Z并不在意两只袜子是不是完整的一双,甚至不在意两只袜子是否一左一右,他却很在意袜子的颜色,毕竟穿两只不同色的袜子会很尴尬。你的任务便是告诉小Z,他有多大的概率抽到两只颜色相
2017-03-10 19:41:48
279
原创 玲珑杯-1103 萌萌哒的第八题(DP+树状数组)
1103 - 萌萌哒的第八题Time Limit:7s Memory Limit:128MByteSubmissions:146Solved:47DESCRIPTION给出两个数列A和B,长度都为n,分别编号都是从1到n,再给出m个数对(c, d),表示A数列的地c个数可以跟B数列的第d个数匹配,当这两个数被匹配上了,那么总分加上这两个数,但
2017-03-05 15:32:52
364
原创 玲珑杯-1101 萌萌哒的第六题(乱搞)
1101 - 萌萌哒的第六题Time Limit:2s Memory Limit:128MByteSubmissions:306Solved:104DESCRIPTION一个凸多边形的每个角都是RGB三种颜色的其中一种,保证相邻的两个点颜色都不一样,请问是否能用多条不相交的对角线把多边形切成多个三角形,使得每个三角形的三个角颜色都不一样。
2017-03-05 14:23:22
384
原创 hdu 3605-Escape(网络流SAP模板+缩点)
EscapeTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 9647 Accepted Submission(s): 2293Problem Description2012 If this is the
2017-02-28 21:13:20
300
原创 SPOJ - Horace and his primes(素数+二分查找)
TAP2013H - Horace and his primesno tags [The original version of this problem (in Spanish) can be found athttp://www.dc.uba.ar/events/icpc/download/problems/tap2013-problems.pdf]Horace
2016-12-31 21:46:50
389
原创 玲珑杯 1066(“玲珑杯”ACM比赛 Round #6)(区间DP+四边形不等式优化)
1066 - Buy CandyTime Limit:1s Memory Limit:1024MByteSubmissions:185Solved:39DESCRIPTIONPigVan ( Mr.Van's pet ) encounter a hard problem in his school. There are n groups
2016-12-23 21:53:33
277
原创 poj 2155 - Matrix(二维树状数组)
MatrixTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 25606 Accepted: 9478DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j]
2016-12-23 21:48:47
254
原创 POJ 1061青蛙的约会(扩展欧几里得)
该题方程很明显可以列出设t为所需步数,则x+nt-y-nt = pL (p为整数)即 (n-m)t+pL = x-y扩展欧几里得的作用是求出形如ax+by = gcd(a,b)的最小解故先求出 (n-m)t+pL = gcd(n-m,L)的解然后此时判断是否 (n-m)t+pL = x-y 有解显然,当(x-y)%gcd(n-m,L)=0,则有解故,在(n-m)t+pL =
2016-11-28 20:42:16
324
原创 hdu 5514(容斥原理)
DescriptionThere are stones lying on a circle, and frogs are jumping over them. The stones are numbered from to and the frogs are numbered from to . The -th frog can jump over exactly stones i
2016-10-18 20:35:10
423
原创 hdu 4135 Co-prime(容斥原理)
#include #include #include using namespace std;#define LL __int64LL p[100005]; int tol = 0;void init(LL n){ tol = 0; for (int i = 2; i*i < n; i++) { if (n%i == 0) { p[tol++] = i;
2016-10-18 17:58:48
230
原创 HDU 4289 - Control(最大流-ISAP模板)
Description You, the head of Department of Security, recently received a top-secret information that a group of terrorists is planning to transport some WMD 1 from one city (the source) to anothe
2016-10-17 17:29:38
280
原创 HDU - 1695 GCD(欧拉函数+容斥原理)
DescriptionGiven 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be ver
2016-10-17 17:26:06
299
转载 HDU 4280 (网络流Dinic算法)
转自:http://www.cnblogs.com/liuxin13/p/4717668.html#include #include #include #include using namespace std;const int maxn = 100005;const int oo = 1e9 + 7;int x, y, n, m;int source = oo, si
2016-09-30 22:04:16
347
原创 poj-2195 Going-Home(最小费用最大流)
DescriptionOn a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little
2016-09-30 19:30:30
314
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅