A、B是两个n*n的矩阵,计算C=A*B。 传统算法: 按照下面公式计算,需要n3次乘法和n3-n2次加法,时间复杂度为Θ(n3)。 递归算法: 假定n为2的幂,将A、B、C分成4个大小为(n/2)*(n/2)的子矩阵。 用分治法来计算C。需要8次(n/2)*(n/2)矩阵的乘法和4次(n/2)*( ...
分类:
其他好文 时间:
2016-10-22 18:08:11
阅读次数:
253
生成树 *题意:给出n个点,m条边,边有两种,求一棵生成树,使得这棵树中的两种边数量相等。 ...
分类:
其他好文 时间:
2016-10-22 17:51:00
阅读次数:
251
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5791 题意:给两个数列,求有多少个公共子序列。 dp(i,j)表示a1~ai和b1~bj的公共子序列个数,当ai==bj的时候,dp(i,j)=dp(i-1,j)+dp(i,j-1)+1。否则dp(i, ...
分类:
其他好文 时间:
2016-10-22 17:14:37
阅读次数:
114
1. 并查集相关的题目 2. Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all ...
分类:
其他好文 时间:
2016-10-22 17:09:00
阅读次数:
188
#include <iostream> #include <iomanip> #include <cmath> using namespace std; //your code will be hereclass Land { public: Land() : price_(0) {} explic ...
分类:
其他好文 时间:
2016-10-22 15:00:05
阅读次数:
140
#include<iostream>#include<cmath>using namespace std;int main(){ int a,b,c; cin>>a>>b>>c; long long sum=1; for(int i=1;i<=b;i++){ sum = sum*a%c; } cou ...
分类:
其他好文 时间:
2016-10-22 14:59:32
阅读次数:
120
#include<iostream>using namespace std;int main(){ int n; while(cin>>n&&n!=0&&n<=4){ int t; int max=0; for(int i=0;i<n;i++){ cin>>t; if(t>max) max=t; } ...
分类:
其他好文 时间:
2016-10-22 14:54:48
阅读次数:
224
Pieces Assignment My Tags (Edit) Source : zhouguyue Time limit : 1 sec Memory limit : 64 M Submitted : 539, Accepted : 190 Source : zhouguyue Time lim ...
分类:
其他好文 时间:
2016-10-22 14:54:15
阅读次数:
208
求子串 数据结构中对串的5种最小操作子集:串赋值,串比较,求串长,串连接,求子串,其他操作均可在该子集上实现 数据结构中串的模式匹配 数据结构中串的模式匹配 KPM模式匹配算法 基本的模式匹配算法 看的出来,每当匹配不成功时,i总是回朔本次匹配的开始位置KPM,一种改进了的模式匹配算法,解决i回朔问 ...
分类:
其他好文 时间:
2016-10-22 14:46:17
阅读次数:
181
#include<iostream>#include<sstream>#include<iomanip>using namespace std;int main(){ int integer; string str; double doulb; while(cin>>str){ stringstre ...
分类:
其他好文 时间:
2016-10-22 14:43:43
阅读次数:
135