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

Автор petoor, история, 7 лет назад, По-английски

Hey guys.

I am new to submitting in python, my code is as follows:

n = int(input()) k = int(input())

if(divmod(n,2)[1]==0): stop_odd = n/2 else: stop_odd= n/2+1 if(k<stop_odd): answer = k*2-1 else: k = k-stop_odd answer = k*2 if(k==0): answer=n-1

print(int(answer))

It is for the problem 318A — Even Odds.

Can anyone tell me why i see the exit code, as the code seems to compile and run in my own editor.

Thanks.

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

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

can you send submission link?

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

int(input()) reads a line but in problem n and k are inputted in one line. So, write n,k = input().split(' ')) . Click.

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

    Further question. Is there any information about which packages i can import? This code is unnecessary bad due to a lack of ceil and floor functions. Can i load python math?

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

      Sorry, I don't know python good, I just know very basics of it.

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

      You should be able to import all libraries that come with a default installation of Python. Like math, fractions, ...

      Libraries that you have to install afterwards (e.g. with pip) will not work.