Redian新闻
>
uneaten leaves这道题到底怎么解好?
avatar
uneaten leaves这道题到底怎么解好?# JobHunting - 待字闺中
m*g
1
在ebiz上逛了一段时间了,可是对神医,护士,病人,毒药这几个术语还是概念比较模
糊,哪位
高手能科普一下。
多谢多谢!
avatar
w*u
2
如果毛毛虫数量多于3,这个求交集的运算也变得很麻烦。到底用inclusion-exclusion
principle解是最好的吗?
There are a large number of leaves eaten by caterpillars. There are 'K"'
caterpillars which jump onto the leaves in a pre-determined sequence. All
caterpillars start at position 0 and jump onto the leaves at positions 1,2,3
...,N. Note that there is no leaf at position 0.
Each caterpillar has an associated 'jump-number'. Let the jump-number of the
i-th caterpillar be A [i]. A caterpillar with jump number 7 keeps eating
leaves in the order 1,241,3*1,... till it reaches the end of the leaves - i.
e, it eats the leaves at the positions which are multiples of /'.
Given a set 'A' of 'IC elements. 'e<=15.,. 'N'<=109, we need to determine
the number of uneaten leaves.
Input Format:
N -number of leaves
A - Given array of integers
Output Format:
An integer denoting the number of uneaten leaves.
Sample Input:
N = 10
A = [2,4,5]
Sample Output:
4
Explanation
1,3,7,9 are the leaves which are never eaten. All leaves which are multiples
of 2, 4, and 5 have been eaten.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。