
简单算法
Karmen Yang
ACM菜鸡
展开
-
暑假专题1 搜索入门
E - Fliptile (POJ 3279)DescriptionFarmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in which they manipulate ...原创 2019-07-20 14:49:24 · 374 阅读 · 0 评论 -
2017 EC final J(差分)
题目题意:有n种扑克牌,每种扑克牌有ai张,每次可以打出3到5张连续的牌作为顺子,问这副牌能不能用顺子全打出来.思路:又差分序列的性质可知,对于序列a[i],求出差分序列b[i]=a[i]-a[i-1],差分序列前k项和sum[k]=a[k]。题目给出了a[1]……a[n],我们求出差分序列b[1]……b[n],令b[n+1]=0-a[n],那么最后的sum[n+1]=0.我们(条件允许)打出...原创 2019-11-17 19:54:06 · 221 阅读 · 0 评论 -
概率DP入门题
关键在于找递推关系POJ2096题意:一个软件有s个子系统,会产生n种bug一个人每天发现一个bug,这个bug属于一个子系统,属于一种分类每个bug属于某个子系统的概率是1/s,属于某种分类的概率是1/n问发现n种bug,每个子系统都发现bug的天数的期望。递推式:dp[i][j]表示发现i个bug输入j个子系统的期望:dp[i][j]= i/n * j/s dp[i][j] ...原创 2019-11-16 21:32:23 · 179 阅读 · 0 评论 -
树形dp求树的直径
求树的直径#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=100005;int n,m,t,ans;int f1[N],f2[N];int first[N],v[N],w[N];int nex[N];void add(int...原创 2019-11-15 17:34:06 · 224 阅读 · 0 评论 -
LCIS
给一个序列a和序列b,求他们的最长公共上升子序列///LCIS 最长公共上升子序列 #include<cstdio>#include<algorithm>using namespace std;int a[555],b[555],dp[555];//dp[i]表示以b[j]结尾的序列的LCIS长度为多少 int path[555],pre[555],ans=0;...原创 2019-11-02 16:38:52 · 200 阅读 · 0 评论 -
差分入门
洛谷 P3078 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main(){ long long n,a[2]={0,0},ans=0; scanf("%lld",&n); for(int i=1;i&...原创 2019-10-01 16:28:47 · 124 阅读 · 0 评论 -
区间最值问题(RMQ)-----ST算法入门
如题Balanced Lineup -POJ3264Time Limit: 5000MSMemory Limit: 65536KTotal Submissions: 76570Accepted: 35063Case Time Limit: 2000MSDescriptionFor the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50...原创 2019-10-01 16:24:41 · 202 阅读 · 0 评论 -
暑假专题3,状压DP 区间DP
状压DPA - Corn Fields POJ3254DescriptionFarmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the c...原创 2019-08-02 10:26:39 · 485 阅读 · 0 评论 -
暑假专题2,DP入门
1、LCS(最长公共子序列)B - Common Subsequencesubsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, …, xm > another sequence Z...原创 2019-07-31 10:04:41 · 238 阅读 · 0 评论 -
C - Emergency Evacuation
Problem C Emergency EvacuationTime Limit: 3 secondsThe Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only inc...原创 2019-10-05 11:03:59 · 414 阅读 · 0 评论