LCM Walk HDU - 5584】的更多相关文章

题目链接: L - LCM Walk HDU - 5584 题目大意:首先是T组测试样例,然后给你x和y,这个指的是终点.然后问你有多少个起点能走到这个x和y.每一次走的规则是(m1,m2)到(m1+lcm(m1,m2),m2)或者(m1,m2+lcm(m1,m2)). 具体思路: lcm(m1,m2)=m1*m2/(gcd(m1,m2)).然后m1就能表示成t1*gcd(m1,m2),m2能表示成t2*gcd(m1,m2).然后(m1,m2)就能走到(t1*gcd(m1,m2),t2*gcd(…
A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map of infinite rows and columns. Rows are numbered 1,2,⋯ from the bottom, so are the columns. At first the frog is si…
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map o…
LCM Walk Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 47    Accepted Submission(s): 31 Problem Description A frog has just learned some number theory, and can't wait to show his ability to hi…
题目链接:LCM Walk Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 491    Accepted Submission(s): 254 Problem Description A frog has just learned some number theory, and can't wait to show his abili…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5584 题意:(x, y)经过一次操作可以变成(x+z, y)或(x, y+z)现在给你个点(ex, ey)输出有多少种可能的起点,这些起点经过若干次操作能变成(ex, ey). 思路:我们考虑其中的一次变换,现在为(x, y)(y > x)那么它显然是由(x, y - z)变换来的.其中z = lcm(x, y - z),lcm(x, y - z) = x*(y-z)/gcd(x, y - z).…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5584 题意: 分析: 这题比赛的时候卡了很久,一直在用数论的方法解决. 其实从终点往前推就可以发现,整个过程中的点的gcd都是一样的,利用这个性质倒着搜索一遍就好了. 相同的gcd均为gcd(6,10) 以(6,10)为例,假设倒数第二个点到达(6−x∗gcd,10),那么x=(6−x∗gcd)∗10/gcd,设6=k1∗gcd, 10=k2∗gcd,那么x满足x=k1∗k2/(k2+1),每次只…
Problem Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog ,,⋯ from the bottom, so are the columns. At first the frog is sitting at grid (sx,sy), and begins his journey. To show…
没用运用好式子...想想其实很简单,首先应该分析,由于每次加一个LCM是大于等于其中任何一个数的,那么我LCM加在哪个数上面,那个数就是会变成大的,这样想,我们就知道,每个(x,y)对应就一种情况. 第二个突破口是,那个式子,我们可以想一想,是不是可以把数进行拆分,我们发现 a=x*k,b=y*k;其中k=gcd(a,b) 并且 x和y互质,这样带入式子,这样我们就把(x*k,y*k)推到了(x*k,x*y+x*y*k),化简即k *(x,(x+1)*y),gcd仍然是k,反过来,我们只需要保证…
A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map of infinite rows and columns. Rows are numbered 1,2,⋯from the bottom, so are the columns. At first the frog is sit…