![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM算法
文章平均质量分 76
liar771
学习是一种信仰
展开
-
ACM所有算法
转载自:http://blog.sina.com.cn/s/blog_adb6743801019h29.htmlACM 所有算法数据结构栈,队列,链表哈希表,哈希数组堆,优先队列双端队列可并堆左偏堆二叉查找树Treap伸展树并查集集合计数问题二分图的识别平衡二叉树二叉排序树线段树转载 2017-03-20 18:14:18 · 377 阅读 · 0 评论 -
Estrella's Travel
Estrella's Travel题目描述Estrella喜欢旅行,她准备去自己心仪的城市看风景。她精心选择了一条线路,准备自驾游。自驾线路是一条链路,上有n+1座城市,编号依次为0∼n,Estrella住在0号城市,目的地是n号城市。Estrella为了环保,驾驶了一辆纯电动车,所以最多只能一次行驶m个城市的距离。如果Estrella在某个城市(包括n号城市)停留,自然会需要一些费用,当原创 2016-12-19 20:19:15 · 835 阅读 · 0 评论 -
NYOJ311完全背包
完全背包时间限制:3000 ms | 内存限制:65535 KB难度:4描述直接说题意,完全背包定义有N种物品和一个容量为V的背包,每种物品都有无限件可用。第i种物品的体积是c,价值是w。求解将哪些物品装入背包可使这些物品的体积总和不超过背包容量,且价值总和最大。本题要求是背包恰好装满背包时,求出最大价值总和是多少。如果不能恰好装满背包,输出NO输入第一原创 2016-12-20 20:12:01 · 413 阅读 · 0 评论 -
最长公共子序列(滚动数组优化)
在网上看过无数的LCS代码,写的非常长,空间时间优化也不咋的,拿来学习非常浪费时间,代码如下。递归公式如下,不理解公共子序列的同学,好好看下面两张图,详情可以参考算法导论。#include using namespace std;int main(){ int i,j,dp[2][10086],t; char a[10086],b[10086]; bo原创 2016-12-25 15:44:02 · 2315 阅读 · 0 评论 -
Balance(动态规划)
BalanceAccepted : 206 Submit : 1023Time Limit : 1000 MS Memory Limit : 65536 KBBalance题目描述小明有一架天平,小明想称出1∼n克的物品,请问最少需要几颗砝码?比如小明想称出1∼4克的物品,需要2颗砝原创 2016-12-29 15:30:06 · 557 阅读 · 0 评论 -
UVALive 6955 Finding Lines
随机化算法优化时间复杂度两点连成一线,遍历n-2个点是否在线上,随机抽取1000组,组数越多误差越小。#includeusing namespace std;int main(){ double n,p; int i,j,l,k; paira[100010]; while(~scanf("%lf%lf",&n,&p)) { p=原创 2017-01-02 15:53:47 · 325 阅读 · 0 评论 -
Linearian Colony SPOJ - COLONY
DescriptionLinearians are pecurliar creatures. They are odd in several ways:Every Linearian is either red or blue.A Linearian colony is a straight line, aligned N-S with the magentic field.A col原创 2017-01-02 16:44:25 · 324 阅读 · 0 评论 -
LightOJ - 1259 Goldbach`s Conjecture
题意:给一个数n,求两个素数a解法:筛法素数打表,把素数存起来,然后每输入一个n,从2开始的素数a,寻找n-a是否存在。注意,一定要把素数存起来判断,不能用bool型数组把10^7的数判断一遍,会超时。#include#include#includeusing namespace std;#define M 10000001bool a[M];int str[10000原创 2017-01-05 14:19:57 · 239 阅读 · 0 评论 -
Max Sum HDU - 1003
Given a sequence a1,a2,a3......an, your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. InputThe fir原创 2017-01-06 12:56:44 · 288 阅读 · 0 评论 -
Intersection CodeForces - 21B(最大公约数gcd)
You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0.Write the program which finds t原创 2017-01-06 13:28:23 · 347 阅读 · 0 评论 -
find the nth digit HDU - 1597
假设: S1 = 1 S2 = 12 S3 = 123 S4 = 1234 ......... S9 = 123456789 S10 = 1234567891 S11 = 12345678912 ............ S18 = 123456789123456789 .................. 现在我们把所有的串连接起来 S = 1原创 2017-01-06 13:31:11 · 309 阅读 · 0 评论 -
Steps POJ - 2590(数学推导???规律吧!!!)
好题,非常好,gooooooooooooooooooooooooooooooooooooooooooooooooood充分锻炼了一个人的耐性,智商。One steps through integer points of the straight line. The length of a step must be nonnegative and can be by one bigger原创 2017-01-06 16:18:02 · 377 阅读 · 0 评论 -
HDU 1045 Fire Net(建模,用二分匹配)
参考kuangbin教主的解法,链接http://www.cnblogs.com/kuangbin/archive/2011/08/09/2132830.html。但是感觉他的建模有点问题.Suppose that we have a square city with straight streets. A map of a city is a square board with n原创 2017-01-11 13:04:33 · 292 阅读 · 0 评论 -
STL容器用法详解
参考:http://www.cnblogs.com/duoduo369/archive/2012/04/12/2439118.html参考:http://blog.csdn.net/pcsuite/article/details/61835041.STL容器分类:STL的容器可以分为以下几个大类: 一 顺序容器,vector, list, deque, string,s原创 2017-01-12 21:09:57 · 1266 阅读 · 0 评论 -
Finally,Which light is on?
Finally,Which light is on?Accepted : 238 Submit : 1065Time Limit : 1000 MS Memory Limit : 65536 KBFinally, which light is on?题目描述有n盏灯,编号1~n。一开原创 2016-12-19 16:22:13 · 216 阅读 · 0 评论