随笔分类 -  PKU

 
POJ 2976
摘要:http://poj.org/problem?id=297601分数规划问题,可以舍掉k组01分数规划用于解决的经典问题是最优比率生成树解法见http://www.cnblogs.com/lotus3x/archive/2009/03/21/1418480.html#include #includ... 阅读全文
posted @ 2015-06-18 19:34 LegendaryAC 阅读(205) 评论(0) 推荐(0)
POJ 1182
摘要:http://poj.org/problem?id=1182带权并查集第一题,三种类型的生物,分别加入三个集合,题解见注释#include #include #include using namespace std ;#define MAX_N 150005int par[MAX_N] ;//父亲 ... 阅读全文
posted @ 2014-07-10 00:52 LegendaryAC 阅读(228) 评论(0) 推荐(0)
POJ 1951
摘要:把给定字符串翻译成目标字符串需要满足的条件是:1、开头不能有空格2、末尾不能有空格3、给定标点前不能有空格4、不能有A、E、I、O、U5、空格不能和空格相邻6、相同的字母只能出现1次给出一组测试数据('_'表示空格):input_I_AM_M._outputM.这道题是水题,但是我忽视了一点导致错误。形如"_I_AM_M._"这个输入。我开始的方法是从头扫空格,遇到字母就停下,这样I前的空格很容易就去掉了,但是像此种情况,I和A都是要去掉的字母,而I和A之间又有空格,这样的结果就是输出的M前会多一个空格,PE。避免这种错误的方法很简单,只要得要ans数组以后 阅读全文
posted @ 2013-10-31 21:40 LegendaryAC 阅读(462) 评论(0) 推荐(0)
POJ 1269 Intersecting Lines
摘要:http://poj.org/problem?id=1269两条直线,平行输出NONE,共线输出LINE,相交输出交点坐标p0为交点,求交点坐标的方法是(p1-p0)X(p2-p0)=0 && (p3-p0)X(p4-p0)=0(其中X代表向量叉乘),联立两个方程可求解求得解分母为0时,判断一条直线中的一个点是否在另一条直线上(用上面叉乘的方法),如果是就共线,反之平行View Code #include <iostream>#include <stdio.h>using namespace std ;struct point{ int x,y ;} ; 阅读全文
posted @ 2012-08-03 11:53 LegendaryAC 阅读(190) 评论(0) 推荐(0)
POJ 1949 Chores
摘要:http://poj.org/problem?id=1949一句话破题,“Farmer John's list of chores is nicely ordered, and chore K (K > 1) can have only chores 1,.K-1 as prerequisites.”View Code #include <iostream>using namespace std ;int dp[10001] ;int main(){ int n ; while(~scanf("%d",&n)) { int w,k,maxx 阅读全文
posted @ 2012-07-23 22:01 LegendaryAC 阅读(187) 评论(0) 推荐(0)
POJ 3230 Travel
摘要:http://poj.org/problem?id=3230dp[i][j]表示第i天在城市j取得的最大价值这题要注意初始化,最大价值可能是负的。View Code #include <iostream>using namespace std ;int cost[101][101],income[101][101] ;int dp[101][101] ;int main(){ int n,m ; while(scanf("%d%d",&n,&m),n||m) { for(int i=1;i<=n;i++) for(int j=1;j< 阅读全文
posted @ 2012-07-23 17:19 LegendaryAC 阅读(114) 评论(0) 推荐(0)
POJ 1088 滑雪
摘要:http://poj.org/problem?id=1088dp的方法实在卡的不会做。。。搜索搞了View Code #include <iostream>using namespace std ;int map[101][101],dp[101][101] ;int r,c ;int dfs(int x,int y){ int tab[4][2]={1,0,-1,0,0,1,0,-1} ; if(dp[x][y]) return dp[x][y] ; int maxx=0 ; for(int i=0;i<4;i++) { int xx... 阅读全文
posted @ 2012-07-23 15:57 LegendaryAC 阅读(136) 评论(0) 推荐(0)
POJ 2533 Longest Ordered Subsequence
摘要:http://poj.org/problem?id=2533最长上升子序列,dpView Code #include <stdio.h>#include <string.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int main(){ int n,i,j; int a[1100],dp[1100]; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf(&quo 阅读全文
posted @ 2012-04-22 20:55 LegendaryAC 阅读(163) 评论(0) 推荐(0)
POJ 1004 Financial Management
摘要:http://poj.org/problem?id=1004求12个数的平均数、、、太无耻了View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { double s,a[13]; int i; while(~scanf("%lf",&a[0])) { s=a[0]; for(i=1;i<12;i++) { scanf("%lf",a+i); s+=a[... 阅读全文
posted @ 2012-04-05 12:16 LegendaryAC 阅读(130) 评论(0) 推荐(0)
POJ 2027 No Brainer
摘要:http://poj.org/problem?id=2027判断a<b......脸皮这两天又厚了不少、、、这种题也拿来充数、、、忏悔ingView Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int t; int a,b; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b); if(a<b 阅读全文
posted @ 2012-04-05 12:11 LegendaryAC 阅读(300) 评论(0) 推荐(0)
POJ 2017 Speed Limit
摘要:http://poj.org/problem?id=2017按题意计算路程,直接算View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int n,i; int s[20],t[20]; int ans; while(scanf("%d",&n),n!=-1) { for(i=0;i<n;i++) scanf("%d%d",s+i,t+i); ans=s[0 阅读全文
posted @ 2012-04-05 12:01 LegendaryAC 阅读(173) 评论(0) 推荐(0)