Блог пользователя paramvi

Автор paramvi, 11 лет назад, По-английски

We need to find all numbers between i,j which have 'D' as it's lowest common divisor(LCD). By LCD 'D' of n, I mean there don't exist any number 1<d<D, which divides n.

Constraints : 1<=i<=j<=2*10^9; 1<=D<=2*10^9;

If the constraints hadn't been that much large, it can be trivially solved using sieve of Eratosthenes.

Solution to this problem is appreciated.

Example : lets i,j,D have values 4,16,5 respectively.

So the answer will be following set of numbers: 5. Here 10,15 are not in the answer because 10 is divisible by 5 as well as 2, which is less than 5. Same for 15. Hope it clarify the doubts.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Where is this problem from?

»
11 лет назад, скрыть # |
 
Проголосовать: нравится -29 Проголосовать: не нравится

what do you mean "lowest common divisor" ? you dont know any single thing about maths.

»
11 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why is it common divisor?

»
11 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +4 Проголосовать: не нравится

The name still a bit confuses me but if I understand statement correctly I have idea how to calculate the number of such numbers(You just can't print them all fast if d = 2)

I will solve the problem for i=1, j=n.(Excercise: how to solve it with i > 1?)

We need to find all number that are less or equal to n/d and don't have divisors strictly less than d. Suppose d>100, then n/d<=2e7 and you can just use sieve to find smallest divisor for every number in O(n/d)

If d < 100 then there are at most 25 primes less than n and you could use inclusive-exclusive principle to calc those number.