Subject:
Code:
#!/bin/python3
import os
import sys
#
# Complete the pageCount function below.
#
def pageCount(n, p):
#
# Write your code here.
#
if (p <= n):
return min(p//2, n//2 - p//2)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
p = int(input())
result = pageCount(n, p)
fptr.write(str(result) + '\n')
fptr.close()
Because you already know which page you want to turn to, that is, the position is already known, so it can be used directly to find the minimum value.
If you feel good, please like and follow the message~
Thank you for joining us~