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

Автор kebab_enjoyer, история, 23 месяца назад, По-английски

Python is overrated

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

»
23 месяца назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

It's an easy alternative when $$$A[i] > 10^{19}$$$

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится +14 Проголосовать: не нравится

    __int128, java bigInteger

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    And that is never, except when numbers have like 100000 digits and need to be read as string.

    • »
      »
      »
      23 месяца назад, # ^ |
      Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

      There was one problem where numbers had size $$$4\cdot 10^{36}$$$ (see 1656H - Одинаковые НОК подмножеств), but I don't think the time limit is very Python-friendly either case, and C++ already has __int128; though one thing to note is that you still have to read input as a string and then convert it to a 128-bit int; output had similar concerns.

      By the way, I'm pretty sure that you can't read a 100000-digit integer as a Python int because I don't know of a way to convert a number of length $$$n$$$ to binary in faster than $$$O(n^2)$$$ time.

      • »
        »
        »
        »
        23 месяца назад, # ^ |
          Проголосовать: нравится +14 Проголосовать: не нравится

        I'm pretty sure that you can't read a 100000-digit integer as a Python int

        Sure you can read 100000-digit integer in python (161330597).

        I think there is something smarter than plain $$$O(n^2)$$$ algorithm ($$$2^{32}$$$ base for digits already should give some speed-up, and maybe you can do some cool optimizations from fact that for parsing you need multipliing only by ten).

        • »
          »
          »
          »
          »
          23 месяца назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Wow, thanks for telling me!

          However, even given the simplicity of the code, it took the code over 1 second to run; I won't count on the other operations to be anywhere near efficient, because of all the binary conversions.

          • »
            »
            »
            »
            »
            »
            23 месяца назад, # ^ |
            Rev. 2   Проголосовать: нравится +6 Проголосовать: не нравится

            oh, also, in addition to my explanation below, let me note that this amount of runtime is likely not entirely an issue of computing numbers! there were $$$100$$$ lines of input, $$$100 000 + 6 = 100 006$$$ bytes each, which comes to a maximum input size of a whopping $$$10 000 603$$$-byte ($$$10 MB$$$!) input. considering that he did not use Fast IO, I think about half the runtime went to processing the input. see my submission (161178040) for a solution that uses PyPy 3 and Fast IO.

      • »
        »
        »
        »
        23 месяца назад, # ^ |
          Проголосовать: нравится +6 Проголосовать: не нравится

        reading a 100000-digit integer, isn't a very big issue by itself in Python, noting that Python integers are essentially big arrays of 64-bit integers. neither is addition or subtraction a big issue. however, big integer multiplication can (and usually do) be a pain in the arse for Python! Python uses the Karatsuba algorithm to multiply big integers, and this algorithm has a $$$O(n^{log_2 3})$$$ time complexity, which can still escalate quite quickly, though faster than an $$$O(n^2)$$$ time complexity multiplication. (using the Decimal type is a possible circumvention to this time complexity, as it is known to be using a Number Theoretic Transform-based implementation for very large numbers). so the point is, while big integer support is a very convenient feature of Python, we at least need to know how fast (or SLOW in some cases!) it works before we use it.

»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can't agree more

»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Yo!

»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Which language do u prefer to train ML models?

»
23 месяца назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

»
23 месяца назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

I think it's not wise to say some languages are good/bad without a specific field.

Just like you won't use python for CP, and won't use C/C++ for Web application(well, I know CGI) and deep learning(still, I know Caffe).

»
23 месяца назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

++++++++++ [>+>+++>+++++++> ++++++++++<<<<-] >>>----.>+++++++ +++++++.------ -----------.++++++++ .+++++.--------. +++++++++++++++.--- ---------------.+++++ +++.<<++.>>--.++ ++++++++.<<.>>++.- ------.------ ----.+.++++ +++++++++..-- ------------- --.++++++++++++++++ +++.----------- ----.-.<<++++ ++++++++++.

»
19 месяцев назад, # |
  Проголосовать: нравится -18 Проголосовать: не нравится

Python is terrible,its high precison calculations make the contest unfair.Hope Codeforces can forbidden python in contests.

  • »
    »
    19 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +22 Проголосовать: не нравится

    Think before you speak.

    • »
      »
      »
      19 месяцев назад, # ^ |
        Проголосовать: нравится -9 Проголосовать: не нравится

      So you want to use Python in CSP,NOIP and NOI?If that happens,nobody will learn other programming languages.

      • »
        »
        »
        »
        19 месяцев назад, # ^ |
          Проголосовать: нравится +8 Проголосовать: не нравится

        Other competitions that do support Python clearly exist. OIs on a few countries (i.e. South Korea) and the ICPC WF are great examples.

      • »
        »
        »
        »
        19 месяцев назад, # ^ |
          Проголосовать: нравится -9 Проголосовать: не нравится

        WTF,IOI allows using Python?!!As if I hadn't said anything.Use international standards as the standard

  • »
    »
    19 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +6 Проголосовать: не нравится

    You: "forbid Python please"

    Java, Ruby, and the several more languages with BigInteger support: Allow us to introduce ourselves.

    C++ Technical Specification P1889 aka "Numerics TS 1": Yes I am indeed jealous of this feature

  • »
    »
    19 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Part of what makes a good coder is knowing when to use what language. Plus, with C++ you can copy a bigint template somewhere either way.

    • »
      »
      »
      19 месяцев назад, # ^ |
        Проголосовать: нравится -8 Проголосовать: не нравится

      Then that's more troublesome because you have to write it yourself.And using Python in contests may make the contest unfair.

      • »
        »
        »
        »
        19 месяцев назад, # ^ |
          Проголосовать: нравится +8 Проголосовать: не нравится

        What's your point? Every language provides slightly different libraries anyways. Also, writing a simple BigInteger class yourself only takes a few minutes.

      • »
        »
        »
        »
        19 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится
        have to write it yourself
        

        Google: exists

        Seriously, it takes no more than a minute to look up a template and copy it. The fact that you can do so here is one reason why such problems are allowed here.