Achha...ji's blog

By Achha...ji, history, 8 days 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

»
8 days 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])

  • »
    »
    7 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    @actium Bro I made this change now it isn't showing that error , but it is returning wrong answer for the square root calculation...and again the same is working totally fine in my compiler.... Still confused

»
7 days 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.

  • »
    »
    5 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Still not working out...even after initializing the res value

»
5 days 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$$$.