摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4360思路:首先就是要寻找最短路了,然后就是要着“LOVE”连着最多的最短路了,这里我们可以用一个二维数组来记录“LOVE”最多的最短路,然后每次spfa更新的时候维护一下就可以了(每当以‘E'结尾是就要num[i][j]++),最后的情况就是要考虑一下特判n==1是的情况了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 阅读全文
posted @ 2013-05-30 21:52 ihge2k 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4396思路:dist[i][j]表示到顶点i走了k条路所花费的最小时间,为了节省内存,当j>=k时,直接令j=k即可,然后就是二维spfa求最短路了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 #include<vector> 7 using namespace 阅读全文
posted @ 2013-05-30 15:53 ihge2k 阅读(353) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2608思路:T[n]为1时当且仅当n为某数的平方或者是某数平方的2倍。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 typedef long long LL; 8 9 int main(){10 int _case,n,ans,k;11 scanf("%d",&_case);12 while(_case--){13 scanf("%d", 阅读全文
posted @ 2013-05-30 13:07 ihge2k 阅读(227) 评论(0) 推荐(0) 编辑