HDU6331 Problem M. Walking Plan 题意: 给出一张有\(N\)个点的有向图,有\(q\)次询问,每次询问从\(s\)到\(t\)且最少走\(k\)条边的最短路径是多少 \(N\le 50, q\le 10^5, k\le 10^4\) 题解: 如果暴力预处理的话复杂度是\(kN^3\)也就是\(1.25\times 10^9\),空间上肯定开不起 第二个想法就是对邻接矩阵进行矩阵快速幂,对于每次询问都要跑一次,复杂度是\(qN^3\log k\)复杂度更高了 考虑分…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6331 Walking Plan  Problem Description There are n intersections in Bytetown, connected with m one way streets. Little Q likes sport walking very much, he plans to walk for q days. On the i -th day, Little…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6325                                   Interstellar Travel Problem Description After trying hard for many years, Little Q has finally received an astronaut license. To celebrate the fact, he intends to buy…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322 Problem Description In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n that are relatively prime to n . It can be defined more formally as the number…
Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.  Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone ss. Input There are multiple test cases.…
Little Q and Little T are playing a game on a tree. There are n vertices on the tree, labeled by 1,2,...,n , connected by n−1 bidirectional edges. The i -th vertex has the value of wi .In this game, Little Q needs to grab some vertices on the tree. H…
hiaki has an array of nn positive integers. You are told some facts about the array: for every two elements aiai and ajaj in the subarray al..ral..r (l≤i<j≤rl≤i<j≤r), ai≠ajai≠aj holds.  Chiaki would like to find a lexicographically minimal array whi…
Chiaki has 3n3n points p1,p2,-,p3np1,p2,-,p3n. It is guaranteed that no three points are collinear.  Chiaki would like to construct nn disjoint triangles where each vertex comes from the 3n3n points. Input There are multiple test cases. The first lin…
Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y+zn=x+y+z, x∣nx∣n, y∣ny∣n, z∣nz∣n and xyzxyz is maximum. Input There are multiple test cases. The first line of input contains an integer TT (1≤T≤1061…
传送门 题目大意 给你一个n点m条边的有向图,q次询问,给定s,t,k,求由s到t至少经过k条边的最短路. 分析 我们设dp[i][j][k]为从i到j至少经过k条边的最短路,sp[i][j]意为从i到j只经过一条边的最短路,于是我们可以得到转移方程式:dp[i][k]=Min{dp[i][m][k-1]+sp[m][j]}.但是我们发现这个样复杂度并不行,于是我们考虑分块,定每一个块的大小为100,对于小于等于100的所有k我们使用上面的dp式子暴力预处理,在这之后我们将按以上方式求出的k=1…