Please read the new rule regarding the restriction on the use of AI tools. ×

Pumpkinizer's blog

By Pumpkinizer, 9 years ago, In English

I just submitted 160A - Twins , in my compiler "codeblocks" it works perfectly and the initial tests are correct, it retruned wrong answer on test 1 when I submitted so I tested it in the custom test where I'm sure I put the exact same code, it returns wrong answer...

can anyone help me and explain what is the problem here ?

![ ](Hebergeur d'image)

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

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

your code is wrong in my compiler too...

»
9 years ago, # |
  Vote: I like it +5 Vote: I do not like it

You didn't initialize the variable sum.

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Well thank you for correcting, although my code is still a wrong solution . the problem is that I still don't understand why does my compiler gives a different result other than codeforces's compiler...

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it +14 Vote: I do not like it

      If you didn't initialize the variable, it can have any value. E.g:

      int main() {
          int i;
          printf("%d\n", i);
      }
      

      That print might print anything, and it might even be different when you run the same executable twice. It's essentially your fault for writing code that uses the value of an uninitialized variable.

      By the way, code::blocks is not a compiler.