Achha...ji's blog

By Achha...ji, history, 3 years ago, In English

This is the error I am getting while I am submitting the code for this problem , and I am not able to figure out the problem as it is giving correct answer on my computer's compiler (GNU GCC) . If someone can identify the cause of the issue please look after it. Here is the link to my solution: https://codeforces.com/contest/230/submission/98808853

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

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Rewrite if(soe[t.first] && t.second) as if(t.second && soe[t.first])

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Initialise res value in sqrt_binary function. If the while loop doesn't execute you will have the uninitialized value usage because res was never assigned any value.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

The sieve is wrong

for(ll j = (ll)i*i ; j <= maxN ; j += i) {
    soe[j] = 0;
}

Take a look at this line for(ll j = (ll)i*i ; j <= maxN ; j += i), you are starting at $$$i^2$$$ instead of $$$2i$$$.