qingyuge006's blog

By qingyuge006, history, 5 years ago, In English

Why do I get the "division by zero" error in this? https://codeforces.net/contest/1183/submission/56306470 I will be more than appreciated if you help me!

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

hope it help

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

    Yes, I know that.......I am just wondering what caused this problem

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

      maybe it understand the line as ans[k] % (a[j] != 0)

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

        Oh thank you. But I have tried it( add parentheses), but failed

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

          I tried if(a[j] == 0) return 0; in the for loop it give WA on test 5

          and diagnose : This application has requested the Runtime to terminate it in an unusual way.

          when the statement : a[i] >= 2

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
          Rev. 2   Vote: I like it +8 Vote: I do not like it

          ok so you used set in the start so a[j] might get to 0

          try to add if(j >= (int)a.size()) return 0; to the same for

          it get WA on test 5 instead of RTE

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
          Rev. 2   Vote: I like it +8 Vote: I do not like it

          here you go I add the line n = a.size()

          see 56307859

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

            Oh I see! a.size() may not be equal to n!!!! THX A Lot!!!