01 2015 档案
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1159题意 : 给出两个字符串 求出最长公共子序列思路: if(str1[i]==str2[j]) { dp...
阅读全文
摘要:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=17322裸最大连续子序列 竟然差点拿来当区间dp来做= =#include #include using namespace std; #define INF 100000...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2602题意 : n个骨头 m的容量 给出n个骨头的 value 和 volume 求m能容纳的最大价值思路 : dp[j]=max(dp[j],dp[j-w[i]]+v[i]);#include#i...
阅读全文
摘要:算法入门经典 训练指南 p189#include#include#include#include#includeusing namespace std;struct Item{ int s,b; Item(int s,int b) :s(s),b(b) {} bool operat...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1272这题要求任意两个房间都相通又不能有环即通过并查集求出是否构成最小生成树#include#include#include#includeusing namespace std;#define maxn 1000...
阅读全文
摘要:题意 :交换相邻的两个数来排序 最少交换几次思路:题意可以转化成求 数列中存在几个逆序数可以看作冒泡排序 但是复杂度过高 可以用归并排序 和离散化的树状数组来完成(注意 n#include#include#includeusing namespace std;int a[5000000+100];i...
阅读全文
摘要:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1136#include#include#include#include#includeusi...
阅读全文
摘要:其实这题可以直接用vector#include#include#include#include#include#includeusing namespace std;vector str[1000000+100];int main(){ int n,m; int i,j,k; in...
阅读全文
摘要:用数组模拟栈#include#include#include#includeusing namespace std;char str1[30],str2[30];int sta[30];int main(){ int n; int i,j,k; int ans[100]; w...
阅读全文
摘要:题意 : 有一个特俗的天平 c 个指定的位置 g个给定重量的砝码 问用上所有砝码 使天平平衡的方案有几种思路: dp[i][j+c[k]*g[i]]+=dp[i-1][j]; #include#include#include#includeusing nam...
阅读全文
摘要:题意: 公主被关在 a位置 她的朋友在r位置 路上x位置有恶魔 遇上恶魔花费2 时间 否在时间花费 1 时间 问 最短多少时间 找到公主思路: bfs+ 优先队列(时间短的先出列)#include#include#include#include#include#includeusi...
阅读全文
摘要:http://acm.hdu.edu.cn/status.php?user=515982859&pid=3033&status=5题意: 有n个产品 m金额 k种品牌 每个产品 属于 a 品牌 b的价格 且具有c的价值量 问 在每种品牌至少买一个产品的情况下 最大价值量是多少思路: ...
阅读全文
摘要:#include#include#include#includeusing namespace std;int mat[120][120];int main(){ int c,n; int i,j,k; scanf("%d",&c); while(c--) { ...
阅读全文
摘要:http://poj.org/problem?id=1384题意:给出一个储蓄罐 的空和满时的重量 再给出n种硬币的 value 和 weight 问满足正好装满罐子时的最小价值是多少思路 :if(dp[j]>dp[j-w[i]]+v[i]) dp[j]=dp[j-w[i]]+v[i];...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5144题意 :给出初速度 v 和高度 h 求最远斜抛距离思路:根据物理公式推出 距离s=v*cos(x)*(t1+t2); 再对x从0 到π/2 进行三分#include#include#include...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5143题意 : 有一定数量的 1 2 3 4 要求每三个或以上数字组成等差数列 每个数字用一次 问是否能把数字都用完思路: 等差数列的可能有 1 2 3 , 2 3 4 ,1 2 3 4, 或者三个...
阅读全文
摘要:http://poj.org/problem?id=2533#include#include#include#includeusing namespace std;int num[1000+100];int dp[1000+100];int main(){ int n; int i,j;...
阅读全文
摘要:不明白为什么要放在dp里#include#include#include#includeusing namespace std;int main(){ char add[10]="(max)"; char str[200]; while(scanf("%s",str)!=EOF) ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5142#include#include#include#include#includeusing namespace std;int bin[100];int main(){ int t,n,i,j,k; ...
阅读全文
摘要:#include#include#include#include#includeusing namespace std;#define INF 100000000int u[6000],v[6000],w[6000];int first[6000],next[6000];int coun[6000]...
阅读全文
摘要:#include#include#include#includeusing namespace std;char mat[20][20];int ans[15];int n;bool ok(int x,int y){ int tx,ty; int ans[15]; int temp...
阅读全文
摘要:#include#include#include#includeusing namespace std;char mat[50][50];int n,m;int ans;int op[4][2]={0,1,0,-1,1,0,-1,0};bool ok(int x,int y){ if(0<=x...
阅读全文
摘要:实在太困 题都看错先贴王大神的代码有空再做遍#include #include #include #include #include #include #include using namespace std;typedef __int64 LL;LL h,n;LL now1,now2;LL ans...
阅读全文
摘要:#include#include#include#include#includeusing namespace std;int main(){ double r,x,y,x1,y1; while(scanf("%lf%lf%lf%lf%lf",&r,&x,&y,&x1,&y1)!=EOF...
阅读全文
摘要:http://codeforces.com/contest/507/problem/A#include#include#include#includeusing namespace std;struct Num{ int v; int id;};Num num[100+10];int c...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3519题意 :caocao能够战胜每一个人 战胜智商比他高的加2点智商 否则加1点 问经过辩论后能得到的最高智商值为多少思路:在辩论中一直和智商比自己高的比 把比自己低的...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1716考到题目直接套 next_permutation 没有注意到0不能为首位 结果wa了一整天输出结构也略有些小坑#include#include#include#include#includeusing nam...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1274思路: 找到匹配的区间 之后dfs#include#include#include#include#includeusing namespace std;char str[300];void dfs(int ...
阅读全文
摘要:http://codeforces.com/problemset/problem/494/A题意 有一串字符串由 ( ) # 组成 #代表若干个 ) 问#具体为多少时可以使每个( 都对应一个 )思路 由于可以有多种方式组合 可以默认前 cnt-1 个 #号 与它前一个 ( 匹配 之后...
阅读全文
摘要:http://poj.org/problem?id=2240基本和poj 1860相同 只是把单点变成了任意点 做完1860再做这题就完全把思路套上就过了做完才发现网上的题解都用的是floyd 不过整体思路都是大同小异吧不过在效率上好像就低下了太多(发现原来是cin的原因 真的是深深感到cin的恶意...
阅读全文
摘要:http://poj.org/problem?id=1860题意: 有n种货币 m个交换点 初始为s货币 并由v的面额 每个交换点可以互换两种货币 汇率为r 但是需要c的手续费 而且a换b与 b换a 的汇率和手续费不相同 问nick能否通过交换使货币金额数增加思路: 存在正环的情况下 金...
阅读全文
摘要:http://poj.org/problem?id=3159题意:一个班有n个人 每人分到若干糖果 且u的糖果数不能比v少w个 求第1个人与第n个人最大数量差照着模板spfa+queue果断tle了之后照着题解说的把queue改成stack就过了 但是还不明白为什么会快而且如果用数组直接模拟会比st...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5104#include#include#include#include#includeusing namespace std;int isp[10000+100];int prime[10000];int coun...
阅读全文

浙公网安备 33010602011771号