摘要: 题目:a1*a2*...*an=b1*b2*…*bn,(ai > 1) 给出b序列,求a序列有多少种。先不考虑ai > 1这个条件。可以通过费解b_i的质因子得到如下公式:∏b_i =∏(p_i^k_i);pi是∏bi 的某个质因子。因为a_i 共有n个,所以把每个p_i填到这n个空位置里边去。对于p_i,有C(k_i + n - 1, n - 1);证明见:http://hi.baidu.com/pp_5/blog/item/73798043ec77781f72f05d51.html/cmtid/6aff22f08c5c85a1a50f523d显然,所有的p[]的值为∏C(k_i 阅读全文
posted @ 2012-08-24 16:29 AC_Von 阅读(355) 评论(0) 推荐(0) 编辑
摘要: 当最短路变成二维,就会发生非常有意思的事情。。。问题:给出u v w,表示从u -> v(双向边)所耗的时间为w,又知道没经过一条边,获利为1(对于一天边可以来回走)。求从start到end点,获利至少为k时用的最小时间。。。如果没有那个k,这个问题直接就是st -> ed的最短路。spfa,dijkstra。。。等等现在可以设 dis[i][j]表示到从st到 i点经过边数为j 时的最短路。然后直接spfa,队列中的每个点保留两个值,节点号,和到这个节点的边数。const int N = 100010;const int M = 5024;struct node { int to 阅读全文
posted @ 2012-08-24 09:13 AC_Von 阅读(345) 评论(1) 推荐(0) 编辑
摘要: 写个类,以后到这里找就行。^_^const int M = 5024;struct node { int to; int val; int next;} g[N<<1];class Graph {public: int head[M], t; void init() { CL(head, 0XFF); t = 0; } void add(int u, int v, int w) { g[t].to = v; g[t].val = w; g[t].next = head[u]; head[u] = t++; ... 阅读全文
posted @ 2012-08-24 09:02 AC_Von 阅读(178) 评论(0) 推荐(0) 编辑