2013年9月3日

POJ 1061 扩展欧几里得

摘要: 1 #include 2 #include 3 4 typedef long long ll; 5 6 void gcd(ll a,ll b,ll& d,ll& x,ll& y){ 7 if(b==0){ 8 d=a; x=1; y=0; return ; 9 ... 阅读全文

posted @ 2013-09-03 09:42 Stomach_ache 阅读(117) 评论(0) 推荐(0) 编辑

2013年9月1日

HDU 1690 最短路

摘要: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef __int64 ll; 8 #define inf 0x3f3f3f3f 9 //#define inf 0x7f7f7f7f7f7f7f... 阅读全文

posted @ 2013-09-01 11:26 Stomach_ache 阅读(105) 评论(0) 推荐(0) 编辑

2013年8月31日

NYoj 155最短路

摘要: 1 //dij 2 #include 3 4 #include 5 #include 6 using namespace std; 7 #define inf 0x3f3f3f3f 8 #define min(x,y) (x<y?x:y) 9 10 int N,M,P,Q;11 int city... 阅读全文

posted @ 2013-08-31 22:24 Stomach_ache 阅读(113) 评论(0) 推荐(0) 编辑

2013年8月28日

HDU 2686 双进程DP

摘要: 1 //第一次遇到这种DP,看大牛的博客都是用最大流求解的。。。dp[k][i][j] 表示走k步,第一条路线横向走了i步,第二条路线横向走了j步,所获得的最大值。。 2 3 //转移方程也很好想 4 #include 5 6 #include 7 #define Max(x,y) (x>y... 阅读全文

posted @ 2013-08-28 16:33 Stomach_ache 阅读(139) 评论(0) 推荐(0) 编辑

2013年8月27日

HDU 4006优先队列

摘要: 1 //按照降序排列,而且队列中只保存k个元素 2 3 #include 4 5 #include 6 using namespace std; 7 8 int main(){ 9 int n,k;10 while(~scanf("%d%d",&n,&k)){11 ... 阅读全文

posted @ 2013-08-27 20:44 Stomach_ache 阅读(110) 评论(0) 推荐(0) 编辑

HDU 4022 STL

摘要: 1 // 使用map > 实现一对多,因为会有重点,所以用multimap 2 3 4 #include 5 6 #include 7 #include 8 #include 9 using namespace std;10 11 map > cnt_x,cnt_y;12 13 int ma... 阅读全文

posted @ 2013-08-27 20:01 Stomach_ache 阅读(132) 评论(0) 推荐(0) 编辑

2013年8月21日

HDU 2639 第K大背包问题

摘要: 1 //状态方程和01背包类似,dp[j][k]表示背包容量为j的第k大背包的值。。。。。。。。。。 2 3 //应当注意的是此时dp[j][1.....k]应当是递减的。。。。。。。。。。。。。。。。。。。。 4 5 6 #include 7 8 #include 9 #define M... 阅读全文

posted @ 2013-08-21 13:47 Stomach_ache 阅读(151) 评论(0) 推荐(0) 编辑

2013年8月12日

HDU 2196

摘要: 1 //树形DP,求树的最大直径。。。。 2 #include 3 4 #include 5 #include 6 using namespace std; 7 #define Max(x,y) (x>y?x:y) 8 #define max 10000+5 9 10 vector next[m... 阅读全文

posted @ 2013-08-12 18:50 Stomach_ache 阅读(153) 评论(0) 推荐(0) 编辑

HDU 3853

摘要: 1 // 第一次做概率DP,根本不懂。。。看了题解还是不懂。尼马!!!!!! 2 3 //只是听人家说什么求概率要正推,求期望要逆推。。。尼马还是不懂!!!! 4 5 //于是找了个水题做了一个,特么的还是不懂!!!! 6 7 //这是个开始,,,慢慢来 8 。。。。。。。。。。。。。。。。... 阅读全文

posted @ 2013-08-12 18:49 Stomach_ache 阅读(263) 评论(0) 推荐(0) 编辑

2013年8月11日

HDU 3555 (递推&&记忆化)

摘要: #include#include#define max 25typedef __int64 LL;LL dp[max][3];//dp[i][0] 不含49//dp[i][1] 不含49但最高位为9//dp[i][2] 含49void init(){ memset(dp,0,sizeof... 阅读全文

posted @ 2013-08-11 15:15 Stomach_ache 阅读(122) 评论(0) 推荐(0) 编辑

导航