摘要: Longest path on DAGFind the longest path on directed acyclic graphG.InputThe first line contains two integersn,m, which denote the number of vertices and edges.The followingmlines contains two integerai,bi, which denote edgeai→bi.(1≤n≤105,1≤m≤106,1≤ai #include using namespace std; const int mm=6e6+9 阅读全文
posted @ 2013-03-09 16:39 剑不飞 阅读(223) 评论(0) 推荐(0) 编辑
摘要: PackingThe cost of set{(a1,b1),(a2,b2),…,(an,bn)}is defined asmax{ai}×max{bi}Partition set{(a1,b1),(a2,b2),…,(an,bn)}into several non-empty subsets to minimize the sum of the cost of subsets.InputThe first line contains an integern.nlines follow. Each of them contains two integerai,bi.(1≤n≤1000 阅读全文
posted @ 2013-03-09 15:08 剑不飞 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Geometric sumCompute(a+a2+…an)modm.InputThree integersa,n,m.(1≤a,n,m≤1018)OutputThe only integer denotes the result.Sample input2 2 1000000000Sample output6 思路;看代码吧#include #include using namespace std; long long c,x,n; long long mul(long long a,long long b)///(a*b)%c { long long ret=0; a%=c;b%=c;.. 阅读全文
posted @ 2013-03-09 14:23 剑不飞 阅读(246) 评论(0) 推荐(0) 编辑