随笔分类 -  算法

摘要:一般矩阵乘法算法: 原理:矩阵相乘最重要的方法是一般矩阵乘积。它只有在第一个矩阵的栏数(column)和第二个矩阵的列数(row)相同时才有定义。一般单指矩阵乘积时,指的便是一般矩阵乘积。若A为m×n矩阵,B为n×p矩阵,则他们的乘积AB会是一个m×p矩阵。其乘积矩阵的元素如下面式子得出: 代码如下 阅读全文
posted @ 2014-10-06 14:08 wuyudong 阅读(12880) 评论(9) 推荐(4)
摘要:本文地址:http://www.cnblogs.com/archimedes/p/recursive-practice.html,转载请注明源地址。1、炮弹一样的球状物体,能够堆积成一个金字塔,在顶端有一个炮弹,它坐落在一个4个炮弹组成的层面上,而这4个炮弹又坐落在一个9个炮弹组成的层面上,以此类推... 阅读全文
posted @ 2014-05-22 23:21 wuyudong 阅读(1445) 评论(0) 推荐(1)
摘要:有一类与数位有关的区间统计问题。这类问题往往具有比较浓厚的数学味道,无法暴力求解,需要在数位上进行递推等操作。这类问题往往需要一些预处理,这就用到了数位DP。本文地址:http://www.cnblogs.com/archimedes/p/numerical-digit-dp.html,转载请注明源... 阅读全文
posted @ 2014-05-22 23:05 wuyudong 阅读(2130) 评论(1) 推荐(2)
摘要:引言 算法程序形式化设计和证明是确保算法程序逻辑结构正确的最理想途径,是保证软件可靠性的有效手段之一;而体现了算法程序本质特征的循环不变式在算法程序形式化方法中具有十分重要的作用。循环不变式是程序设计理论中的一个重要概念。这一概念的建立在程序设计从艺术走向科学这一历 史性的转变过程中起着巨大的推动... 阅读全文
posted @ 2014-05-21 13:51 wuyudong 阅读(3546) 评论(0) 推荐(3)
摘要:位图法定义位图法就是bitmap的缩写,所谓bitmap,是用每一位来存放某种状态,适用于大规模数据,但数据状态又不是很多的情况。通常是用来判断某个数据存不存在的。例如,要判断一千万个人的状态,每个人只有两种状态:男人,女人,可以用0,1表示。那么就可以开一个int数组,一个int有32个位,就可以... 阅读全文
posted @ 2014-05-21 06:51 wuyudong 阅读(7440) 评论(0) 推荐(3)
摘要:21、Amicable numbers Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, 阅读全文
posted @ 2014-05-02 00:25 wuyudong 阅读(820) 评论(0) 推荐(0)
摘要:hdoj2044--一只小蜜蜂...Problem Description有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。其中,蜂房的结构如下所示。Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a... 阅读全文
posted @ 2014-04-21 15:02 wuyudong 阅读(695) 评论(0) 推荐(1)
摘要:11、Largest product in a grid In the 2020 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 0 阅读全文
posted @ 2014-04-09 00:21 wuyudong 阅读(975) 评论(0) 推荐(0)
摘要:6、Sum square difference Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 385 = 2 阅读全文
posted @ 2014-04-08 22:26 wuyudong 阅读(677) 评论(0) 推荐(0)
摘要:1、Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 2 阅读全文
posted @ 2014-04-08 00:38 wuyudong 阅读(505) 评论(2) 推荐(0)
摘要:1001--Sum Problem(http://acm.hdu.edu.cn/showproblem.php?pid=1001)#include int sum(int n){ if(n % 2) return (n + 1) / 2 * n; else ... 阅读全文
posted @ 2014-04-05 19:50 wuyudong 阅读(451) 评论(0) 推荐(0)
摘要:所谓的快速幂,实际上是快速幂取模的缩写,简单的说,就是快速的求一个幂式的模(余)。在程序设计过程中,经常要去求一些大数对于某个数的余数,为了得到更快、计算范围更大的算法,产生了快速幂取模算法。我们先从简单的例子入手:求abmodc算法1.直接设计这个算法:int ans = 1;for(int i = 1;i0) { if(b % 2 = = 1) ans = (ans * a) % c; b = b/2; a = (a * a) % c; } return ans;}本算法的时间复杂度为O(logb),能在几乎所有的程序设计... 阅读全文
posted @ 2014-04-01 04:01 wuyudong 阅读(14589) 评论(1) 推荐(14)

Top_arrow