mahmoud_osama08's blog

By mahmoud_osama08, history, 4 weeks ago, In English

Today we teach the ability to perform range queries in $$$\mathcal{O}(1)$$$, regardless of the query rekwaired.

Consider $$$Q = [l, r]$$$.

Iterate over all quadraubles $$$\left(a,b,c,d\right)$$$, add $$$Q[a]\times Q[b]\times Q[c] - Q[d]^2$$$

Now to solve single qwery, output $$$\text{Quadruble}[l][r^2][r-l^r][l+r^l]$$$.

The precomputation took $$$\mathcal{O}(1)$$$ time because $$$a,b,c,d\le 10^{18}$$$, a constant

You solve every query in $$$\mathcal{O}(1)$$$ cuz u immediately output the formula.

if you dont trust me, try it in this problem

you can see that my code is fastest ($$$0.00$$$ s)

  • Vote: I like it
  • -35
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it +16 Vote: I do not like it

Get a life.

»
4 weeks ago, # |
Rev. 3   Vote: I like it -10 Vote: I do not like it

The following sieve is O(1) time fr

bool composite[100'001]; 
int main () {
   for (int i = 2; i * i <= 100'000; i++) {
      if (!composite[i]) {
         for (int j = 2 * i; j <= 100'000; j += i) composite[j] = 1;
      }
   }
}
»
3 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

One can process everything that the program might receive in "O(1)" time since it's always bounded. How to process it is an another story.