MasterMynk's blog

By MasterMynk, history, 4 years ago, In English

Hi, I'm trying to solve 110A - Nearly Lucky Number and I'm stuck on test 7 89120446. On my PC I get the output as YES but in Codeforces it shows that my output is NO. What could I do to fix this?

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

| Write comment?
»
4 years ago, # |
  Vote: I like it +5 Vote: I do not like it

The input overflows, you would need to use unsigned long long instead of 32-bit type. If it works on your PC that indicates that your local compiler is 64 bit based instead of 32.

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

    So is the compiler on Codeforces 32-bit?

    • »
      »
      »
      4 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Hey, you have written a wrong solution, in the first place. You need to check if the count of the number of lucky digits in it is a lucky number. What you have done is checking if the count is 4 or 7.

      Look here : 60278851

      Spoiler

      UPD : The solution is right. I should have been more observant :)

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

        Ummm... But I actual changed inp(a variable in the program) from unsigned long to unsigned long long, submitted the result and the solution got accepted. I don't think my solution is wrong then right?

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

          Ahh.. okay, what I had done was slightly more general. You have got an AC, because the number of digits is at max 19, as per the constraints. Ya so, the count has to be either 4 or 7 (smallest 2 digit lucky number is 44 > 18). It's perfectly correct.

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

        I think his solution is ok. The number of lucky digits in the number will be at most 19 because N <= 10^18 and the only lucky numbers which are <= 19 are 4 and 7.

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

      There are several to choose from, you submitted as c++17, which is 32-bit. There is a 64-bit version of c++17 available, too. Just choose it from the combo box.