算法
文章平均质量分 52
Yihui_He
Deep Learning, Computer Vision, AI, Computer Network
展开
-
Even Parity Uva 11464 ,
写的时候多打了个叹号... 坑了很久#include #include #include using namespace std;int main(){ int answer = 0; int n; scanf("%d", &n); int mat[17][17]; int vis[17][17]; memset(vis, 0,原创 2015-01-29 01:06:58 · 622 阅读 · 0 评论 -
支持向量机(三)核函数
7 核函数(Kernels) 考虑我们最初在“线性回归”中提出的问题,特征是房子的面积x,这里的x是实数,结果y是房子的价格。假设我们从样本点的分布中看到x和y符合3次曲线,那么我们希望使用x的三次多项式来逼近这些样本点。那么首先需要将特征x扩展到三维,然后寻找特征和结果之间的模型。我们将这种特征变换称作特征映射(feature mapping)。映射函数称作,在这个例子中转载 2015-03-28 22:50:20 · 833 阅读 · 0 评论 -
[数学模型]整数规划(一)
整数规划问题比较简单, 主要解法分为这几种:(i)分枝定界法—可求纯或混合整数线性规划。 (ii)割平面法—可求纯或混合整数线性规划。 (iii)隐枚举法—求解“0-1”整数规划: ①过滤隐枚举法; ②分枝隐枚举法。 (iv)匈牙利法—解决指派问题(“0-1”规划特殊情形)。 (v)蒙特卡洛法—求解各种类型规划。 分支定界法branch a原创 2015-04-02 23:33:10 · 5217 阅读 · 1 评论 -
[编程之美]资格赛 B Palindrome
既然这个是资格赛, 时间也比较充裕, 我就讲解一下我做题的过程Time Limit:2000msCase Time Limit:1000msMemory Limit:256MBDescriptionGiven a string, calculate the number of subsequences that are palindrome.原创 2015-04-18 11:55:48 · 844 阅读 · 0 评论 -
字符串匹配
实现支持如下特性的字符串匹配程序: (1) ’?’可匹配任意字符 0 次或者 1 次,如“a?”可匹配”a”或者” ”; (2) ’.’可匹配任意单个字符; (3) ’*’可匹配任意字符任意多次,如“a*”可匹配” ”,”a”,”aa”… (4) ‘+’可匹配任意字符至少 1 次,如”a+”可匹配”a”,”aa”…(该项可选) 输入:模式字符串和待匹配字符串原创 2015-04-13 20:14:36 · 552 阅读 · 0 评论 -
[shuju]一道简单题 Uva 11991
#include #include #include using namespace std;int main(){ map > a; int n, int m; while (scanf("%d%d", &n, &m) == 2){ for (int i = 0; i < n; i++){ int x; scanf("%d", &x); if (!a.c原创 2015-04-09 16:53:06 · 570 阅读 · 0 评论 -
读取.dex文件中的所有字符串
import structimport os#这里定义一个读取字符串长度的函数def DecUnsignedLEB128(file): result = struct.unpack("i", file.read(4))[0]#读取4字节中的第一个字节 result = result&0x000000ff file.seek(-3, 1) #倒退回前面的第三个字节原创 2015-04-06 15:05:07 · 2165 阅读 · 0 评论 -
数据挖掘基础:在数据中寻找相关的项目 Apriori算法
Ck: Candidate itemset of size kLk : frequent itemset of size kL1 = {frequent items};for (k = 1; Lk !=; k++) do begin Ck+1 = candidates generated from Lk; for each transaction t in databa原创 2015-04-15 16:41:50 · 858 阅读 · 0 评论 -
整数划分问题--DFS
单点时限:1000ms 内存限制:256MB描述 Given two positive integers N and M, please divide N into several integers A1, A2, …, Ak (k >= 1), so that: 1. 0 < A1 < A2 < … < Ak; 2. A1 + A2 + … + Ak = N; 3. A1, A2, …,原创 2015-08-12 09:21:21 · 912 阅读 · 0 评论 -
04-树5 Root of AVL Tree
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is原创 2015-11-26 16:41:52 · 635 阅读 · 0 评论 -
支持向量机SVM(二)
http://www.cnblogs.com/jerrylead6 拉格朗日对偶(Lagrange duality) 先抛开上面的二次规划问题,先来看看存在等式约束的极值问题求法,比如下面的最优化问题: 目标函数是f(w),下面是等式约束。通常解法是引入拉格朗日算子,这里使用来表示算子,得到拉格朗日公式为转载 2015-03-28 20:11:02 · 533 阅读 · 0 评论 -
支持向量机SVM(一)
1 简介支持向量机基本上是最好的有监督学习算法了。最开始接触SVM是去年暑假的时候,老师要求交《统计学习理论》的报告,那时去网上下了一份入门教程,里面讲的很通俗,当时只是大致了解了一些相关概念。这次斯坦福提供的学习材料,让我重新学习了一些SVM知识。我看很多正统的讲法都是从VC 维理论和结构风险最小原理出发,然后引出SVM什么的,还有些资料上来就讲分类超平面什么的。这份材料从前几节讲的logi转载 2015-03-27 16:30:25 · 511 阅读 · 0 评论 -
正整数排序 Help is need for Dexter Uva 11384
面对刚开始没有头绪的题目, 先进行尝试往往是非常有必要的, #include #include using namespace std;unsigned int cal(unsigned int n){ if (n == 1) return 0; else if (n == 2) return 1; else return cal((unsigned int)(n/2原创 2015-01-30 21:07:53 · 920 阅读 · 0 评论 -
长城守卫 Beijing guards CERC 2004 LA3177 解题总结
在最小值,最大值的问题 或者没有办法确定答案时候, 可以使用二分答案法.#include #include #include using namespace std;int main(){ fstream f("E:\\text.txt"); int n; int gift[100]; bool used[100]; memset(used, 0, sizeof(use原创 2015-02-01 18:38:23 · 1525 阅读 · 0 评论 -
[高效算法设计]Calculator conundrum Uva 11549
使用 sstream 方便输入输出, 用于判断某个元素是否被访问过, 在数组开不下的时候可以使用 set集合#include #include #include using namespace std;int next(int n, int k){ stringstream ss; ss << (long long)k*k; string s = ss.str()原创 2015-02-01 23:07:31 · 542 阅读 · 0 评论 -
网络 network,Seoul 2007 LA3902 解题感想
一道关于 DFS 的题目, 关键在于距离 K, 将服务器的节点作为根节点进行DFS#include #include #include using namespace std;const int maxn = 1000 + 10;vector tree[maxn], nodes[maxn];int fa[maxn];int s, k, n;bool covered[ma原创 2015-02-01 17:06:38 · 941 阅读 · 0 评论 -
( 设计高效算法 ) 年龄排序 Age Sort Uva 11462
可以使用整数排序法, 内存太小无法堆排序.#include #include using namespace std;int main(){ unsigned int age[101]; int n,temp; while (scanf("%d", &n) == 1 && n){ memset(age, 0, sizeof(age)); for (int i = 0;原创 2015-02-01 20:58:23 · 691 阅读 · 0 评论 -
动态规划 最长公共子序列 王子和公主 Prince and Princess UVa 10635
#include #include using namespace std;const int maxn = 250 * 250;int main(){ char T; cin >> T; for (char k = 0; k < T;k++) { int n, p, q; cin >> n >> p >> q; int num[maxn]; memset(n原创 2015-02-09 00:14:12 · 1442 阅读 · 0 评论 -
(高效算法设计)之高维问题 废料堆 Garbage heap Uva 10755
#include #include #define FOR(i,s,p) for(int i=(s);i<=(p);i++)using namespace std;void expand(char i, bool b[]){ b[0] = i & 1; i >>= 1; b[1] = i & 1; i >>= 1; b[2] = i & 1;}// 这里使用了二项式中的思想,原创 2015-02-07 15:13:46 · 891 阅读 · 1 评论 -
[动态规划] Sum游戏 ( Game of Sum, Uva 10891 )
抓住状态转移方程即可 : 从子序列 i j 中取最大 = i + 从子序列i+1,j中取最大 或 j + 从子序列i,j-1中取最大#include #include #include using namespace std;const int maxn = 100+10;int S[maxn], A[maxn], d[max原创 2015-03-02 21:11:39 · 996 阅读 · 0 评论 -
[动态规划] 黑客的攻击 Hacker's CrackDown Uva 11825
抽象为数学模型就是, 取尽可能多的互不相交的子集 , 使得每一个子集都能覆盖全集#include #include #include using namespace std;int n;int P[1000],cover[1000],f[1000];int main(){ scanf("%d", &n); for (int i = 0; i < n;i+原创 2015-03-03 22:19:24 · 1129 阅读 · 0 评论 -
[动态规划] 放置街灯 Uva 10859 - Placing Lampposts
我的思路是: 先将每个灯周围的路存储 为 1 其他 路为 0 . 再算出任意几个灯点亮之后的补集, 被重复点亮的路记为2, 只点亮一次的记为1, 没有点亮的是0. 优化公式x=M*a+b, a为 未点亮的灯的个数, b为 标记为2 的路的个数 M为略微大于路总数的一个常数.之后遍历所有子集即可.代码与我上一篇文章类似.原创 2015-03-04 09:23:42 · 747 阅读 · 0 评论 -
代码开源:Channel Pruning for Accelerating Very Deep Neural Networks
代码开源:Channel Pruning for Accelerating Very Deep Neural Networks[PDF] [Code] 基于CNN每一层都是稀疏地假设,我们考虑是否能找到neuron之间的关系,仅留下最具有代表性地neuron?原创 2017-08-22 13:54:05 · 7738 阅读 · 9 评论