摘要:ACM模板【最长上升子序列】输出长度while(scanf("%s%s",s1+1,s2+1)!=EOF) { l1 = strlen(s1+1); l2 = strlen(s2+1); for(i = 0; i f[i][j-1])...
阅读全文
摘要:【序】 整理这个【ACM模板】,主要是为了我们队有一个熟悉进而能快速查询的知识库。 不断完善的过程,也是对自己学习知识的整理,同时对学习过程的记录。 --by chengdongni 2017/7/31 【目录】 1.动态规划 2.图论 3.数学基础 4.字符串 5.搜索 6.数据结构 7.STL 【动态规划】 1.背包问题 2.子序列问题 【图论】 1.最小生成树 2.最短路(+...
阅读全文
摘要:RescueProblem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M #include#include#i...
阅读全文
摘要:Farm IrrigationBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are p...
阅读全文
摘要:胜利大逃亡Problem DescriptionIgnatius被魔王抓走了,有一天魔王出差去了,这可是Ignatius逃亡的好机会.魔王住在一个城堡里,城堡是一个A*B*C的立方体,可以被表示成A个B*C的矩阵,刚开始Ignatius被关在(0,0,0)的位置,离开城堡的门在(A-1,B-1,C-...
阅读全文
摘要:Catch That CowProblem DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a po...
阅读全文
摘要:A strange liftProblem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 #include#include...
阅读全文
摘要:Knight MovesProblem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour ...
阅读全文
摘要:自己用代码实现了一遍queue类的各个函数,具体使用见注释,运行效果见截图ACM模板/*queue被称为队列,是一种先进先出(FIFO)的容器适配器。*/ /*它只允许在一端插入元素操作,在另一端进行删除元素操作*/ /*插入的一端称为队尾,删除的一端称为队头*/ #include//如果要使...
阅读全文
摘要:C Oil DepositsProblem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works w...
阅读全文
摘要:A - Tempter of the Bone Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the ...
阅读全文
摘要:Andy, 8, has a dream - he wants to produce hisvery own dictionary. This is not an easy task forhim, as the number of words that he knows is,well, not ...
阅读全文
摘要:1083: [SCOI2005]繁忙的都市Description 城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造。城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口之间最多有一条道路相连接。这些道路是双向的,且把所有的交...
阅读全文
摘要:Bone Collector IIProblem DescriptionThe title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must ...
阅读全文
摘要:DividingDescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share...
阅读全文
摘要:最大连续子序列Problem Description给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 #include#define N 10000+10int now_start;int max_start,ma...
阅读全文
摘要:Super Jumping! Jumping! Jumping!Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Ma...
阅读全文
摘要:Max SumProblem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,...
阅读全文
摘要:ACM模板void CompletePack(int cost,int weight,int V){//完全背包 int i; for( i = cost; i = cost; i --) dp[i] = max(dp[i],dp[i-cost]+weigh...
阅读全文
摘要:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z ...
阅读全文
摘要:Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不...
阅读全文
摘要:Big Event in HDUProblem DescriptionNowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Comput...
阅读全文
摘要:数塔Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试...
阅读全文
摘要:问题 G: 建设电力系统题目描述小明所在的城市由于下暴雪的原因,电力系统严重受损。许多电力线路被破坏,因此许多村庄与主电网失去了联系。政府想尽快重建电力系统,所以,身为程序员的你被赋予了一项任务,就是编程计算重建电力系统的最少花费,重建的电力系统必须保证任意两个村庄之间至少存在一条通路。输入输入的第...
阅读全文
摘要:ACM模板【kruskal+并查集模板】kruskal的时间复杂度为O(MlogM)#include#include//c++ sort头文件 using namespace std;int f[100];//数组大小按题目所给条件设定 struct edge{ int u,...
阅读全文
摘要:void init()//初始化函数 { int i; for(i = 1; i <= n; i ++) f[i] = i; return;}int find(int v)//查找根结点 { if(f[v] == v) return v; else { //这里是路径压缩,每次在函数返回时,把...
阅读全文
摘要:1. 第一台电脑如何进行编程 二进制编程2. 冯诺依曼机工作原理是什么?如何区分程序和数据 储存程序和程序控制 数据是材料,程序是处理材料的方法和步骤3. 进制如何快速转换,16进制怎么转成10进制?为什么出现8进制和16进制 定义数字初值为零,从前往后每次加上16进制一个...
阅读全文
摘要:问题 A: 丑数题目描述如果一个数的素因子只包含2,3,5或7,那么我们把这种数叫做丑数。序列1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27...展示了前20个丑数。请你编程寻找这个序列中的第n个元素。输入输入包含多组测试数据。每组输入为一个整数...
阅读全文
摘要:问题 C: 迷宫问题题目描述小明置身于一个迷宫,请你帮小明找出从起点到终点的最短路程。小明只能向上下左右四个方向移动。输入输入包含多组测试数据。输入的第一行是一个整数T,表示有T组测试数据。每组输入的第一行是两个整数N和M(1#include#define N 110int book[N][N];c...
阅读全文
摘要:问题 B: 赌徒题目描述有n个赌徒打算赌一局。规则是:每人下一个赌注,赌注为非负整数,且任意两个赌注都不相同。胜者为赌注恰好是其余任意三个人的赌注之和的那个人。如果有多个胜者,我们取赌注最大的那个为最终胜者。例如,A,B,C,D,E分别下赌注为2、3、5、7、12,最终胜者是E,因为12=2+3+7...
阅读全文
摘要:原文地址:BFS广搜题目【经典训练题】【有时间一个个做下来】作者:东方侠者pku 1175 Starry Night题目地址:http://acm.pku.edu.cn/JudgeOnline/problem?id=1175解法:BFS,要注意的是如何判断图形是一样的,我的做法就是计...
阅读全文
摘要:问题 E: 一家人题目描述最近zzq交了一个新朋友叫cj,他们在聊天的时候发现500年前他们竟然是一家人!现在zzq想知道cj是他的长辈,晚辈,还是兄弟。输入输入包含多组测试数据。每组首先输入一个整数N(N#includeint main(){ int a,b; int n,i; int k1,k2...
阅读全文
摘要:问题 A: 构建矩阵题目描述现请你构建一个N*N的矩阵,第i行j列的元素为i与j的乘积。(i,j均从1开始)输入输入的第一行为一个正整数C,表示测试样例的个数。然后是C行测试样例,每行为一个整数N(1int main(){ int t; int n; int i,j; scanf("%d",&t);...
阅读全文
摘要:1743: 算法3-4:表达式求值题目描述算数四则运算的规则是1)先乘除,后加减;2)从左算到右;3)先括号内,后括号外。由此,算式4+2*3-10/5的计算顺序为4+2*3-10/5=4+6-10/5=4+6-2=8。给定一个以“#”作为结束符的算式,求出算式的结果。给出严蔚敏《数据结构(C语言)...
阅读全文
摘要:字符串常用字符串函数查询strcat() 连接字符串函数和memset初始化函数strcat函数原型:#include "string.h"char * __cdecl strcat ( char * dst, const char * src ){ char * cp = d...
阅读全文
摘要:ACMKuangbin大神 cxlove 卿学姐 111qqz
阅读全文
摘要:给出2个大整数A,B,计算A+B的结果。 Input 第1行:大数A 第2行:大数B (A,B的长度 #include#include#define N 10000+10char str1[N],str2[N];int num1[N],num2[N];void Conversion(...
阅读全文