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

Автор kratos99, история, 6 лет назад, По-английски

I need help to solve this problem.

Thanks in advance.

Happy Coding :)

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

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

1.Use Linear Sieve to take primes no more than $$$n$$$ out, store them.

Linear Sieve

2.Use upper_bound() to find the position of the smallest prime strictly greater than $$$n$$$. Then we can calculate $$$\pi(n)$$$ easily.

3.$$$\forall i: i\ge 0 $$$ and $$$ p_{A\times i+B} \le n$$$, store $$$p_{A\times i+B}$$$ for answer.

4.Output what you stored for answer.