【Codeforces 242C】King's Path】的更多相关文章

[链接] 我是链接,点我呀:) [题意] 让你找到(x0,y0)到(x1,y1)的一条最短路 走过的点必须在所给的n个横向路径上 [题解] 因为n条横向路径上的点最多不会超过10的5次方个,所以我们可以把这10的5次方个点全都 和数字1~10^5一一对应. 然后对于这每一个点,分别于相邻的8个点连边. 然后在无向图上做一个广搜就能找到起点到终点的最短路啦 [代码] import java.io.*; import java.util.*; public class Main { static I…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
[题目链接]:http://codeforces.com/contest/534/problem/B [题意] 你在t秒内可以将车的速度任意增加减少绝对值不超过d; 然后要求在一开始车速为v1,t秒之后车速变为v2; 问你这段t时间内,车最多能行驶多远. [题解] 枚举车"最大速度"v 看看车到达这个速度之后,然后回到速度v2(也就是说v是可能小于v2的,所以最大速度加了引号")看看可不可行; 如果能在到达最大速度之后又回到速度v2(在t时间内); 那么记下回到v2的时间t1…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Roman planted a tree consisting of n vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the n …
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph. There are n vertices in the tree, e…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wr…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of n rows…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expe…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The country Treeland consists of n cities connected with n - 1 bidirectional roads in such a way that it's possible to reach every city starting…