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…
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…
题目链接: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),每次只…
没用运用好式子...想想其实很简单,首先应该分析,由于每次加一个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…
http://acm.hdu.edu.cn/showproblem.php?pid=5584 题意: 现在有坐标(x,y),设它们的最小公倍数为k,接下来可以移动到(x+k,y)或者(x,y+k).现在给出终点坐标,求有多少个起点可以通过这种变化方式得到终点. 思路: 现在假设我们处于(x,y)这个坐标上,x和y的最大公约数为k,x和y用k来表示的话可以表示为x=$m_{1}$,y=$m_{2}$. 那么接下来可以得到($m_{1}$k,$m_{2}$k+$m_{1}$$m_{2}$k)或者 (…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5584 给一个坐标(ex, ey),问是由哪几个点走过来的.走的规则是x或者y加上他们的最小公倍数lcm(x, y). 考虑(ex, ey)是由其他点走过来的,不妨设当走到(x,y)时候,gcd(x, y)=k,x=k*m1, y=k*m2. 下一步有可能是(x, y+x*y/gcd(x, y))或者是(x+x*y/gcd(x,y), y). 用k和m1,m2来表示为(k*m1, k*m2+m1*m2…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5312 Sequence Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1336    Accepted Submission(s): 410 Problem Description Today, Soda has learned a…
 LCM Challenge Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Status Practice ACdream 1077 Description Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I…