上一页 1 ··· 91 92 93 94 95 96 97 98 99 ··· 121 下一页
摘要: 题目链接: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 阅读(242) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4293思路:这题dp的状态比较难想,dp[i]表示前i个人最多有多少人说真话,而num[i][j]表示当前人的前面有i个人,后面有j个人的个数,于是有dp[i]=max(dp[i],dp[j]+num[j][n-i])(0<=j<i); 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 #define MAXN 555 6 int n 阅读全文
posted @ 2013-05-29 22:31 ihge2k 阅读(204) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3560思路:dfs判环,这里成环的条件是环中的每个点的出度和入度都为1,因此dfs的时候只须判断的相连的每个点的size()==2即可。ps:为防暴栈手动开栈:#pragma comment(linker,"/STACk:10240000,10240000") 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #in 阅读全文
posted @ 2013-05-29 19:18 ihge2k 阅读(560) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4034思路:要对floyd有深刻的理解才能A这道题,边数最多的情况是每两点之间都有最短的直边相连,故最多为n*(n-1),在每两点都有最短直边相连情况下,我们可以一一删去多余的边,最后就是最终结果。即若dist[i][j]=dist[i][k]+dist[k][j],则i 与 j的这条边可以删去.若dist[i][j]>dist[i][k]+dist[k][j],则说明dist[i][j]并不是最短路,存在矛盾,此时则不存在这样的图,输出impossible。 1 #include 2 #in 阅读全文
posted @ 2013-05-29 18:23 ihge2k 阅读(297) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2648思路:map映射,记录一下memory的位置即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int Point[10010]; 9 10 int main() {11 int n,m,pos,price;12 while(~scanf("%d",&n)) {13 memset(Point,0,sizeof(Point));1. 阅读全文
posted @ 2013-05-28 22:13 ihge2k 阅读(460) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3873思路:题目意思很简单,就是说如果没有攻占保护x的城市,就不能攻占,我们可以用pro[x]记录保护x的所有城市被攻占的最早时间,那么能到x的最短时间为pro[x]和到达x的最短路中的较大者 .dij入队过程中只把In[x](没有被包含的城市)入队 对于出队的x,它的最短时间已经确定,表示已经被占领,它所保护的城市的保护度减1,一旦某个被保护的城市的保护度为零且已经到底(未占领,d[x]!=inf),就可以确定到达它的 最短时间(为max(pro[x],dist[x])),它也就到了入队的时机。 阅读全文
posted @ 2013-05-28 13:26 ihge2k 阅读(910) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3631思路:由于只能用标记的点去更新,并且又要求任意两点之间的最短距离,显然floyd是最合适的。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 #include<vector> 7 using namespace std; 8 #define MAXN 333 9 #de 阅读全文
posted @ 2013-05-23 19:56 ihge2k 阅读(486) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3832思路:三次spfa求出1,2,3到各点的最短距离,然后枚举中间点到这三点的最短距离之和为ans,最后就是n-ans-1了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 #define MAXN 222 8 #define inf 1 阅读全文
posted @ 2013-05-23 17:46 ihge2k 阅读(265) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4528思路:结构体里面不仅要记录x,y,time,还要有2个bool型来记录是否看到二明和大明,因此,对于状态判重,开个4位数组mark[x][y][tag1][tag2],因为根据看到的人不同,我这个点(x,y)还是可以 重复走的,最后就是关于怎么来判断看到的人了,这儿我用了最暴力的方法,就是一开始的时候记录二明和大明所在的位置,然后将其改为'X',因为这两个位置小明是不能走的。然后就是如果横坐标相同,就y方向上看能否看到(同理)。如果对于当前节点p有p.tag1=p.tag2=t 阅读全文
posted @ 2013-05-22 23:28 ihge2k 阅读(255) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1422 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define MAXN 222222 7 int level[MAXN]; 8 int dp[MAXN]; 9 int n,w,l;10 11 int main(){12 while(~scanf("%d",&a 阅读全文
posted @ 2013-05-22 21:50 ihge2k 阅读(222) 评论(0) 推荐(0)
上一页 1 ··· 91 92 93 94 95 96 97 98 99 ··· 121 下一页