多少个志愿服务岗位有哪些? [英] How many postions are there?

查看:150
本文介绍了多少个志愿服务岗位有哪些?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我练了算法的编程疑难问题时遇到的困难,在解决这个疑难问题要想法(只有很小的方法/提示)来解决这个problm efficienty,所以plz帮助我! 这是问题的声明::

I was practising the algorithm based programming problem.I am having difficulty,in solving this problem.I want idea (only small approach/hint)to solve this problm efficienty,so plz help me.! Here Is the problem Statement::

假设有两个兔子,名为兔foo和兔bar.Initially两者都位于原点(中心)彼此面对更为

Suppose there are two rabbits,named rabbit foo and rabbit bar.Initially both of them are located at the origin(center) facing each others.

美孚只​​知道在两个长度米跳,n.That是富能跳要么米长到他的左边或米长到他的右或N长度,他的左边或N长到他 右侧在单一的尝试。

Foo knows jump of only two lengths m,n.That is foo can jump either m length to his left or m length to his right or n length to his left or n length to his right side in a single attempt.

同样栏也知道跳只有两个长度-P的,q.That是巴能跳成p长度,以左手或P的长度在他的右边或q长度,以左手或q长度,以他 右侧在单一的尝试。

Similarly bar also knows jump of only two lengths-p,q.That is bar can jump either p length to his left or p length to his right or q length to his left or q length to his right side in a single attempt.

现在这两只兔子的主人想完全把自己置身在一个点上,这样无论是兔子就能达到他的主人在一个或更多的尝试。 此外,主人将自己至多L个长度远离原点。 我们要计算有多少位大师可以将自己。

Now the master of these two rabbits want to place himself exactly at one point such that both of the rabbits will be able to reach his master in one or more attempts. Also ,the master place himself at most L lengths away from the origin. We have to calculate At how many position the master can place himself.

M,N,​​P,Q和L是非常大的,因为较大的10 ^ 17

m,n,p,q and L are very large ,as larger as 10^17.

因此​​,如何有效地解决这个问题。

So how to solve it efficiently.

例::

M = 1,N = 2

m=1 n=2

M = 4 N = 5

m=4 n=5

L = 1

答案= 3;

foo就可以跳到2的长度,以他的右边,一个长度,他的左侧后。

Foo can jumps 2 length to his right side and after that one length to his left side.

栏可以跳到5的长度,以他的RGT和四个宽​​度对他的左侧后。

Bar can jumps 5 lengths to his rgt and after that four lenth to his left side.

要达到他的师傅是谁的地方1单元远离原点。

to reach his master who is place 1 units away from the origin.

富2长度左,一个长度右侧后。 5条长留和5个长度RGT达到他的主人谁设了自己在1长距原点

Foo 2 length left and after that one length right side. Bar 5 length left and 5 length rgt to reach his master who located himself at 1 length away from origin

法师也可以将自己在原点,因为这两个foo和酒吧将能够达到他的主人在两个动作 所以总持仓= 3。

Master can also place himself at the origin since both foo and bar would be able to reach his master in two moves so total positions=3.

其他的例子::

M = 2 N = 4

m=2 n=4

P = 3 Q = 6

p=3 q=6

L = 7

答案= 3。

M = 10,N = 12

m=10 n=12

P = 3 Q = 9

p=3 q=9

答案= 5

推荐答案

富可达是 GCD(M,N)的倍数的任何位置也只有这些。酒吧可以达到是 GCD(P,Q)的倍数的位置,所以到达双方的立场是 LCM(GCD完全倍数( M,N),GCD(P,Q))

Foo can reach any position that is a multiple of gcd(m,n) and only those. Bar can reach the positions that are multiples of gcd(p,q), so the positions reachable by both are exactly the multiples of lcm(gcd(m,n),gcd(p,q)).

这篇关于多少个志愿服务岗位有哪些?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆