Блог пользователя MasterMynk

Автор MasterMynk, история, 4 года назад, По-английски

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?

  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

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 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    So is the compiler on Codeforces 32-bit?

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      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 года назад, # ^ |
          Проголосовать: нравится +1 Проголосовать: не нравится

        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 года назад, # ^ |
          Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

          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 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        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 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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.