摘要: 题目链接http://www.dotcpp.com/oj/problem1084.html AC代码: #include<iostream> #include<cstring> using namespace std; const int maxn = 1e6+10; // int prime[ma 阅读全文
posted @ 2019-03-08 21:24 looeyWei 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 复杂度O(n) 算法步骤 1、先初始化number数组全为true,代表每个数都为素数,(0和1手动修改为false,因为它们很明显不是素数),然后从数字2开始遍历(显然2是素数) 2、将number为true的放入prime数组中,并使下标+1,然后再遍历prime,将prime中的数的 i 倍的 阅读全文
posted @ 2019-03-08 21:21 looeyWei 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 题目链接http://www.dotcpp.com/oj/problem1004.html?sid=748195&lang=1#editor 找规律 当1<=i<=4 ,a[i]=i 当 i>=5 ,a[i]=a[i-2]+a[i-3]+a[i-4] #include<iostream> using 阅读全文
posted @ 2019-03-08 17:33 looeyWei 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 单点修改,区间查询 可以实现基本操作: 1、给定 i ,x . 给 bit[i] 加上 x 2、给定 l , r . 求出 bit[l] +...+ bit[r] #include<iostream> #include<cmath> #include<cstdio> using namespace 阅读全文
posted @ 2019-03-05 19:31 looeyWei 阅读(270) 评论(0) 推荐(0) 编辑
摘要: Dijkstra 不能判断负环 #include<iostream> #include<functional> #include<queue> #include<algorithm> #include<cstdio> using namespace std; typedef pair<int, in 阅读全文
posted @ 2019-03-04 21:52 looeyWei 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 1、下载Anaconda 2、打开Anaconda,创建python环境 (3.6) , 下载tensorflow_gpu依赖包和bazel依赖包 3、在vs(本人是用vs写python)中搭建python环境,解释器为Anaconda中创建的 阅读全文
posted @ 2019-03-04 12:24 looeyWei 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 原博客地址https://blog.csdn.net/yoer77/article/details/70943462#t8 0-1背包 有n个物品,每个物品都有两个属性:价值v和重量w。有一个容量为W的背包,现要求这些物品尽可能装进背包,并使得价值最大。 因为每种物品只有一个,选或者不选,因此也叫做 阅读全文
posted @ 2019-03-03 21:06 looeyWei 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 任何一个需要用dp解决的问题,都有一个状态转移方程,当前子问题的解由上一个子问题推出 而LIS问题的状态转移方程为: dp[i]=max{dp[i], dp[j]+1} 边界条件:dp[i] = 1 (i=1~n) 限制条件:j<i, a[j] <= a[i] 其中dp[i]表示以第i的为结尾的最长 阅读全文
posted @ 2019-03-03 18:43 looeyWei 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 题目描述 这是一道模板题。 给定一个字符串 A和一个字符串 B,求 B在 A 中的出现次数。A 和 B 中的字符均为英语大写字母或小写字母。 A 中不同位置出现的 B 可重叠。 题目描述 这是一道模板题。 给定一个字符串 A和一个字符串 B,求 B在 A 中的出现次数。A 和 B 中的字符均为英语大 阅读全文
posted @ 2019-03-03 14:22 looeyWei 阅读(340) 评论(0) 推荐(0) 编辑
摘要: KMP 返回s串中匹配p串成功后第一个字符的下标,若要返回位置,则+1 #include<iostream> #include<string> using namespace std; int _next[1000010]; string s, p; void getnext(string p){ 阅读全文
posted @ 2019-03-03 13:55 looeyWei 阅读(101) 评论(0) 推荐(0) 编辑