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

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

Statement

This question is based on bonus of this problem.

We need to count such non-negative integer triple $$$(a, b, c)$$$ that satisfy $$$(0 \leq a + b + c \leq S)$$$ and $$$(0 \leq a \times b \times c \leq T)$$$.

Since the result may be very big, you can either use bignum or modulo $$$10^9 + 7$$$ for convention


Notice that:

  • $$$(0, 0, 1) \neq (0, 1, 0) \neq (1, 0, 0)$$$

Constraint:

  • $$$0 \leq S, T \leq 10^{18}$$$

  • $$$0 \leq a, b, c$$$


No Time Limit. But expect to be 10 seconds


Memory Limit: 1Gb


Input:

  • A single line contain only two positive 60-bit integers $$$S$$$ and $$$T$$$ ($$$0 \leq S, T \leq 10^{18}$$$)

Output:

  • Print a single integer, the number of positive tuple satisfy mathematical condition

Example:

Example 0
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7
Example 8
Example 9
Example 10
Example 11
Example 12
Example 13
Example 14
Example 15

After many hours, the answer for $$$f(10^{18}, 10^{18})$$$ is reached but not confirmed therefore I wont add in the example




Current Research

When $$$S \leq \lfloor \frac{S}{3} \rfloor \times \lfloor \frac{S + 1}{3} \rfloor \times \lfloor \frac{S + 2}{3} \rfloor \leq T$$$. The condition $$$a \times b \times c \leq T$$$ is satisfied, therefore the result is $$$\frac{(S+1)(S+2)(S+3)}{6}$$$

When $$$T = 0$$$, at least one of them must be zero, therefore the result will be $$$\frac{3S(S-1)}{2} + 1$$$

When $$$S = 0$$$, there is only one triple satisfied $$$(0, 0, 0)$$$

When $$$S = T$$$, the function $$$f(S, T) \approx 1.5 S^2$$$ (Tested with $$$10^7$$$ integers $$$n \leq 10^{12}$$$

Without depend on $$$O(f(S))$$$, the best current known algorithm is $$$O(T^{5/9})$$$

Without depend on $$$O(f(T))$$$, the best current known algorithm is $$$O(S^2)$$$ (can be further optimized but not on researched)

Sadly, there were no papers, documentaries, integer sequences or math formulas found to apply this function.

Math discussion for Proof

Used this Paper

Reference Code

Current best known algorithm: O(T^(5/9)) - Used modulo for large result

Note: It is now A347221

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

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

there is no time limit so brute-force is enough

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

You should specify constraints for $$$a, b, c$$$ as well. For example, for any $$$x$$$ there is a solution $$$a = 0, b = x, c = -x$$$, since for those $$$0 \leq a + b + c = 0 + x - x = 0 \leq S$$$ and $$$0 \leq a \cdot b \cdot c = 0 \leq T$$$ and for every $$$S$$$ and $$$T$$$ the answer is infinity.

When you include constraints for $$$a, b, c$$$ as $$$ 0 \leq a, b, c$$$, then constraints $$$0 \leq a + b + c$$$ and $$$0 \leq a \cdot b \cdot c$$$ become redundant ;)

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

I have a question too, how many pairs (x, y) such that x, y >= 0 satisfy following condition: x + y <= S, x * y <= T

(When I was trying these post's problem, I encountered this and I just wonder, thanks.)

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

I think i might have something. WLOG assume x<=y<=z. Note x<=10^6. Iterate for x. After that note that if product is fixed, sum of two numbers is minimal when they are as close to each other as possible. So you can use binary search for rest i think.

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

i think the sample cases are wrong. for example input:

10 10 should give 193

edit: i was wrong it should be 213.

edit2: is there any solution faster than O(s^2)?

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

Spending for 3 days and I cant optimize more, so I decide to quit.

The best I achieve for this problem (which I used to generate the test cases above) is $$$O(S \times T^{\frac{1}{3}})$$$ (use for large T small S) and $$$O(T^{\frac{5}{6}})$$$ (use for large S small T) (both can calculate $$$S = T = 10^{10}$$$ under 1 second)

Good luck to anyone who try to solve this with a better algorithm <3

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

Update: Using integral, my real complexity is actually only $$$O\Huge(\normalsize \overset{min(S, \lfloor \sqrt[3]{T} \rfloor)}{\underset{a = 1}{\Huge \Sigma}} \LARGE( \normalsize log_2(\Large \lfloor \normalsize \sqrt{\frac{T}{a}} \Large \rfloor) \LARGE + \Large \lfloor \normalsize \normalsize \frac{T}{a} \Large \rfloor \LARGE ^{^{\normalsize 1/3}}) \Huge) \normalsize = O\Large( \int_{_{\normalsize 1}}^{^{\normalsize T^{1/3}}}\frac{\normalsize T^{1/3}}{\normalsize a^{1/3}} \normalsize da \Large) \normalsize = O(T^{5/9})$$$

No papers were found to has a better bound

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

Amazing Problem! BTW, I reckon that you're supposed to mention a,b,c are non-negative intergers.