自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(24)
  • 收藏
  • 关注

原创 1004-动态规划

Problem Description阿黄的银行最近有发行了一种新面额的钞票面值为4,所以现在黄有5中面额的钞票,分别是20,10,5,4,1。但是不变的是他的小气(同题2),现在又有很多人来取钱,黄又不开心了,请你算出每个来取钱的人黄应该给他多少张钞票。Input多组样例,每组给出一个n,n为要取出的金额。(nOutput每组样例输出一个答案(

2015-11-28 17:53:02 378

原创 杭电2544-Dijkstra算法

#include #include #include using namespace std;#define maxn 110#define inf 1<<29int N,M;int mapp[maxn][maxn];int d[maxn];int visit[maxn];int s;void Dijkstra(){ int i,j,k; int Min; memse

2015-11-27 23:59:39 290

原创 1002-排列组合

这题习惯性用搜索了,明明知道会超时,依然用了搜索...没想过排列组合这种做法先选行:有Cn,m种做法,再选列:并可交换有An,m所以总共有An,m*Cn,m种方式。题目大意:会长大人由于经常不玩象棋,于是把象棋充公了~奇怪的是象棋里面没有象(这是为什么呢?象棋没有象还怎么玩啊),不过不要紧,我们还有车!好吧,上次马被玩坏了,这次来玩车(本来这次玩象,可是会长表示并不想把

2015-11-22 23:28:21 543

原创 1005-行列式

题目大意:给定a[1],a[2]...a[n],以及x。求:行列式|a[1]  -1  0  ...  0  0 ||a[2]  x  -1  ...  0  0 ||a[3]  0  x  ...  0  0 || .  .  .    .  . || .  .  .    .  . || .  .  .    .  . ||a[n-1]  0  0  ...

2015-11-22 23:10:48 352

原创 1004-递推

题目大意:神秘学妹:薛学长,能请教你一道题吗?薛学霸:好呀好呀!神秘学妹:给你一个数n,则从1,2,3......n中取出3个不同的整数来组成三角形的三条边有多少种方法。薛学霸:............. 输入包含多组测试数据,每组数据第一行为整数n(3输出可以组成的三角形的个数 Input:58Output:32

2015-11-21 23:43:40 271

原创 1003-模拟题

题目大意:给定n, m,输出一个n行m列的数组,数组元素从1到n*m,从左上角开始,按顺时针填充数组,详情见样例 输入包含多组数据,每组数据包含两个正整数n,m,不超过100 对于每组数据,输出一个n行m列的数组 Input:1 12 23 32 4Output:11 24 31 2 38 9 47 6 51 2 3 48

2015-11-21 23:41:40 432

原创 杭电5443 线段树模板

#include #include using namespace std;const int maxn=200001;#define left l,m,rt<<1#define right m+1,r,rt<<1|1int Max[maxn<<2];void UP(int rt){ Max[rt]=max(Max[rt<<1],Max[rt<<1|1]);}void

2015-11-21 00:58:40 212

原创 杭电2094

#include #include #include #include using namespace std;int visit[5000];int main(){ int n,i; string a,b; mapq; int cnt; while(~scanf("%d",&n)&&n) { cnt=1; q.clear(); memset(visit,0,

2015-11-20 22:05:12 354

原创 杭电1285

#include #include #include #include using namespace std;int mapp[600][600];int degree[600];int visit[600];int main(){ int N,M; int i,n,m,num; int p[600]; priority_queue, greater > q; int

2015-11-20 22:04:17 278

原创 杭电1247

#include #include #include using namespace std;int const maxn=26;int sum;string s[60000];struct node{ int Count; node*next[maxn]; node() { Count=0; memset(next,0,sizeof(next)); }};n

2015-11-13 22:17:16 322

原创 杭电1251

#include #include #include typedef struct Trie{ struct Trie *Next[26]; int data;}node;node *root;void Insert(char s[]){ int len=strlen(s); int i; node *p=root; node *q;

2015-11-13 22:07:43 328

原创 杭电2087

#include #include #include using namespace std;char s1[1100],s2[1100];int Next[1100];int sum;void GetNext(){ int len; len=strlen(s2); Next[0]=-1; Next[1]=0; int i=1; in

2015-11-13 21:10:02 459

原创 POJ1961

这题要注意一定要从2到N枚举:且判断条件为两个:前面是为了判断子串满足循环节的整数倍,后面的判断是为了判断子串中至少有两个循环节#include #include #include using namespace std;char s[1000010];int Next[1000010];void Kmp(){ Next[0]=-1; Next[1]=0;

2015-11-13 21:03:56 311

原创 杭电2594

模板稍微改一下就可以了#include #include #include using namespace std;char s1[51000],s2[51000];int Next[51000];void GetNext(){ int len; len=strlen(s2); Next[0]=-1; Next[1]=0; int i=1;

2015-11-13 20:52:31 266

原创 二叉树前序遍历读入和输出模板-递归算法

#include #include typedef struct k{ char data; struct k *left,*right;}node;node *Scan(){ node *t; char ch; if((ch=getchar())=='#')return NULL; t=(node *)malloc(sizeof(node));

2015-11-13 13:45:55 468

原创 杭电2896题 AC自动机模板题

AC自动机的一个常见的例子就是给出n个单词,再给出一段包含m个字符的文章,让你找出有多少个单词在文章里出现过。这题一定要注意建树时为128叉树:#include #include #include #include using namespace std;char number[1000005];struct Trie{ int Next[100010][1

2015-11-10 21:50:27 328

原创 1008

简单题,暴力就可以了题目大意:计算机网络OSI参考模型分为七层,其中有一个层次叫做数据链路层,它有一个功能就是组帧。数据链路层之所以要把比特组合成帧为单位传输,是为了在出错时只重发出错的帧,而不重发全部的数据,从而提高了效率。为了接收方能正确地接收并检查所传输的帧,发送方必须依据一定的规则把网络层递交的分组封装成帧,这个过程称为组帧。组帧主要解决帧定界、帧同步、透明传输等问题。

2015-11-03 21:30:29 332

原创 素数判断 1003

素数筛选法会超时,应该直接判断...#include #include #include #include using namespace std;int main(){ int N,i,m; while(~scanf("%d",&N)) { m=(int)sqrt(N); for(i=2;i<=m;i++) { if(N%i==0) break;

2015-11-03 21:28:35 655

原创 DFS 暴力 1007

题目大意:给定一个n*m的中国象棋棋盘,现在希望放上k只马,这些马之间不能相互攻击,共有多少种方案? 第一行是一个t,代表有t组数据。每一组数据的第一行是n(n接下来是一个n*m的字符矩阵。矩阵中只含有两种字符‘.’,‘#’,‘.’代表是空的,‘#’代表已经有子放在上面了。 总方案数 Sample Input22 3 1......2 3 2...

2015-11-03 20:55:08 315

原创 素数筛选法模板

#include#include#include#include#includeusing namespace std;const int L=100005,inf=1<<30,maxn=1005;int prime[L],np=0;bool is[L];void getPrime(){ fill(is,is+L,1); is[1]=0; for(int

2015-11-01 21:44:39 343

原创 map使用方法 1004 HDU1113

题目大意:In millions of newspapers across the United States there is a word game called Jumble. The object of this game is to solve a riddle, but in order to find the letters that appear in the answer it

2015-11-01 21:32:41 369

原创 线段树成段更新1002 POJ3468

这题本来是道正常题的,结果会长把may not写成may超过64位,我试 unsigned long long试了3次,才注意到有负数,用double交了两次过了后,听说int就能过...内心是崩溃的...题目大意:You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations.

2015-11-01 21:15:45 349

原创 组合数取模

题目大意:组合的定义及其计算公式:从n个不同元素中,任取m(m≤n)个元素并成一组,叫做从n个不同元素中取出m个元素的一个组合;从n个不同元素中取出m(m≤n)个元素的所有组合的个数,叫做从n个不同元素中取出m个元素的组合数。用符号 C(n,m) 表示。测试数据有多组,每组1行,每行2个数n和m(m≤n,n<=1000).输出C(n,m)%1000000007的值方法1:递推加动态规划思想:由组合数递推公式C(n,m)=C(n-1,m-1)+C(n-1,m) 可设dp[i][j]为:

2015-11-01 17:20:24 312

原创 带状矩阵,对称矩阵,三角矩阵

对称矩阵重要公式:*(p+((k*(k+1)/2)+p1)*sizeof(int))= *(p+((p1*(p1+1)/2)+k)*sizeof(int))上三角矩阵重要公式:*(p+((n-k+1)*k+k*(k-1)/2+p1-k)*sizeof(int))带状矩阵重要公式:*(p+((2*b+1)*k-b+p1-k+b)*sizeof(int))

2015-11-01 16:03:27 4918

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除