摘要: 原题链接:http://acm.uestc.edu.cn/problem.php?pid=1732分析:dp,n个相同物品放入m个相同的盒子(允许为空)的个数为dp[n][m]=dp[n][m-1]+dp[n-m][m];dp[n][m-1]表示有空盒的情况,dp[n-m][m]表示没有空盒的情况。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define maxn 101 7 #define mod 1000007 8 using namespace std; 9 int dp[maxn][maxn];10 void s 阅读全文
posted @ 2013-08-31 13:52 EtheGreat 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2722分析:简单最短路,读入数据烦。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 450 9 #define inf 0xfffffff10 using namespace std;11 int blip[maxn];12 int n,m;13 bool vis[maxn];14 struct edge15 {16 int to,w;17 edg... 阅读全文
posted @ 2013-08-29 10:00 EtheGreat 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2363分析:最短路+二分。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define ll long long 10 #define maxn 105 11 #define inf 0x7fffffff 12 using namespace std; 13 int T,n,m,low,up; 14 int h[maxn],map[maxn][ma... 阅读全文
posted @ 2013-08-29 09:51 EtheGreat 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2962分析:最短路+二分。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #define ll long long11 #define inf 100000000012 #define maxn 100513 using namespace std;14 struct edge15 {16 int to,h,len;17 edg... 阅读全文
posted @ 2013-08-29 09:44 EtheGreat 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217分析:floyd. 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #define ll long long11 #define maxn 3312 #define inf 0xfffffff13 using namespace std;14 int n;char cur[30];15 mapm;16 double mapp[maxn][ma 阅读全文
posted @ 2013-08-29 09:32 EtheGreat 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1142分析:最短路+记忆化搜索。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define ll long long 9 #define inf 0x6fffffff10 #define maxn 100511 using namespace std;12 struct edge13 {14 int to,time;15 edge(int x,int y)16 ... 阅读全文
posted @ 2013-08-29 09:27 EtheGreat 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874分析:SPFA|Dijkastra. 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define ll long long 9 #define inf 0x6fffffff10 #define maxn 20511 using namespace std;12 int g[maxn][maxn],dis[maxn],n,m;13 bool vis[maxn];14 void dij 阅读全文
posted @ 2013-08-29 09:22 EtheGreat 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 原题连接:http://acm.hdu.edu.cn/showproblem.php?pid=2066分析:超级源点+SPFA。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define ll long long 9 #define inf 0xfffffff10 #define maxn 100511 using namespace std;12 struct edge13 {14 int to,time;15 edge (int x,int y)16 ... 阅读全文
posted @ 2013-08-29 09:15 EtheGreat 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://www.acm.uestc.edu.cn/problem.php?pid=1267分析:此题麻烦之处在于要输出最小最长上升子序列,关键在于如何解决最小这个问题.我的做法是从最后一个数开始往前扫描,同时另开一重循环,从该数num[i]前一个往前扫描,即j=i-1~0.如果num[j] 2 using namespace std; 3 int num[1005]; 4 int dp[1005]; 5 int nxt[1005]; 6 int main() 7 { 8 int T; 9 scanf("%d",&T);10 while(T--)11 阅读全文
posted @ 2013-08-20 00:30 EtheGreat 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394分析:树状数组的应用。Minimum Inversion Number 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define maxn 5005 7 using namespace std; 8 int c[maxn],num[maxn],n; 9 int low_bit(int i)10 {11 return i&(-i);12 }13 void update(int i,int v)14 {15 w... 阅读全文
posted @ 2013-08-16 22:06 EtheGreat 阅读(147) 评论(0) 推荐(0) 编辑